Panda3D

Public Member Functions | Static Public Member Functions | Friends | List of all members
VirtualFileMount Class Referenceabstract

The abstract base class for a mount definition used within a VirtualFileSystem. More...

`#include "virtualFileMount.h"`

Inheritance diagram for VirtualFileMount:

## Public Member Functions
virtual bool | atomic_compare_and_exchange_contents (const Filename &file, std::string &orig_contents, const std::string &old_contents, const std::string &new_contents)
| See Filename::atomic_compare_and_exchange_contents(). More...
virtual bool | atomic_read_contents (const Filename &file, std::string &contents) const
| See Filename::atomic_read_contents(). More...
virtual void | close_read_file (std::istream *stream) const
| Closes a file opened by a previous call to open_read_file(). More...
virtual void | close_read_write_file (std::iostream *stream)
| Closes a file opened by a previous call to open_read_write_file(). More...
virtual void | close_write_file (std::ostream *stream)
| Closes a file opened by a previous call to open_write_file(). More...
virtual bool | copy_file (const Filename &orig_filename, const Filename &new_filename)
| Attempts to copy the contents of the indicated file to the indicated file. More...
virtual bool | create_file (const Filename &file)
| Attempts to create the indicated file within the mount, if it does not already exist. More...
virtual bool | delete_file (const Filename &file)
| Attempts to delete the indicated file or directory within the mount. More...
virtual TypeHandle | force_init_type ()
virtual std::streamsize | get_file_size (const Filename &file) const =0
virtual std::streamsize | get_file_size (const Filename &file, std::istream *stream) const =0
VirtualFileSystem * | get_file_system () const
| Returns the file system this mount object is attached to. More...
int | get_mount_flags () const
| Returns the set of flags passed by the user to the VirtualFileSystem::mount() command. More...
const Filename & | get_mount_point () const
| Returns the name of the directory within the virtual file system that this mount object is attached to. More...
virtual bool | get_system_info (const Filename &file, SubfileInfo &info)
| Populates the SubfileInfo structure with the data representing where the file actually resides on disk, if this is knowable. More...
virtual time_t | get_timestamp (const Filename &file) const =0
virtual TypeHandle | get_type () const
virtual bool | has_file (const Filename &file) const =0
virtual bool | is_directory (const Filename &file) const =0
virtual bool | is_regular_file (const Filename &file) const =0
virtual bool | is_writable (const Filename &file) const
| Returns true if the named file or directory may be written to, false otherwise. More...
virtual bool | make_directory (const Filename &file)
| Attempts to create the indicated file within the mount, if it does not already exist. More...
virtual PointerTo< VirtualFile > | make_virtual_file (const Filename &local_filename, const Filename &original_filename, bool implicit_pz_file, int open_flags)
| Constructs and returns a new VirtualFile instance that corresponds to the indicated filename within this mount point. More...
virtual std::ostream * | open_append_file (const Filename &file)
| Works like open_write_file(), but the file is opened in append mode. More...
virtual std::iostream * | open_read_append_file (const Filename &file)
| Works like open_read_write_file(), but the file is opened in append mode. More...
virtual std::istream * | open_read_file (const Filename &file) const =0
std::istream * | open_read_file (const Filename &file, bool do_uncompress) const
| Opens the file for reading. More...
virtual std::iostream * | open_read_write_file (const Filename &file, bool truncate)
| Opens the file for writing. More...
std::ostream * | open_write_file (const Filename &file, bool do_compress, bool truncate)
| Opens the file for writing. More...
virtual std::ostream * | open_write_file (const Filename &file, bool truncate)
| Opens the file for writing. More...
virtual void | output (std::ostream &out) const
virtual bool | read_file (const Filename &file, bool do_uncompress, vector_uchar &result) const
| Fills up the indicated pvector with the contents of the file, if it is a regular file. More...
virtual bool | rename_file (const Filename &orig_filename, const Filename &new_filename)
| Attempts to rename the contents of the indicated file to the indicated file. More...
virtual bool | scan_directory (vector_string &contents, const Filename &dir) const =0
virtual void | write (std::ostream &out) const
virtual bool | write_file (const Filename &file, bool do_compress, const unsigned char *data, size_t data_size)
| Writes the indicated data to the file, if it is a writable file. More...
Public Member Functions inherited from TypedReferenceCount
| TypedReferenceCount (const TypedReferenceCount &copy)
void | operator= (const TypedReferenceCount &copy)
Public Member Functions inherited from TypedObject
| TypedObject (const TypedObject &copy)=default
TypedObject * | as_typed_object ()
| Returns the object, upcast (if necessary) to a TypedObject pointer. More...
const TypedObject * | as_typed_object () const
| Returns the object, upcast (if necessary) to a TypedObject pointer. More...
int | get_best_parent_from_Set (const std::set< int > &) const
int | get_type_index () const
| Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More...
bool | is_exact_type (TypeHandle handle) const
| Returns true if the current object is the indicated type exactly. More...
bool | is_of_type (TypeHandle handle) const
| Returns true if the current object is or derives from the indicated type. More...
TypedObject & | operator= (const TypedObject &copy)=default
Public Member Functions inherited from MemoryBase
void | operator delete (void *, void *)
void | operator delete (void *ptr)
void | operator delete[] (void *, void *)
void | operator delete[] (void *ptr)
void * | operator new (size_t size)
void * | operator new (size_t size, void *ptr)
void * | operator new[] (size_t size)
void * | operator new[] (size_t size, void *ptr)
Public Member Functions inherited from ReferenceCount
int | get_ref_count () const
WeakReferenceList * | get_weak_list () const
| Returns the WeakReferenceList associated with this ReferenceCount object. More...
bool | has_weak_list () const
| Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More...
void | local_object ()
| This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More...
void | ref () const
| Explicitly increments the reference count. More...
bool | ref_if_nonzero () const
| Atomically increases the reference count of this object if it is not zero. More...
bool | test_ref_count_integrity () const
| Does some easy checks to make sure that the reference count isn't completely bogus. More...
bool | test_ref_count_nonzero () const
| Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More...
virtual bool | unref () const
| Explicitly decrements the reference count. More...
bool | unref_if_one () const
| Atomically decreases the reference count of this object if it is one. More...
WeakReferenceList * | weak_ref ()
| Adds the indicated PointerToVoid as a weak reference to this object. More...
void | weak_unref ()
| Removes the indicated PointerToVoid as a weak reference to this object. More...

## Static Public Member Functions
static TypeHandle | get_class_type ()
static void | init_type ()
Static Public Member Functions inherited from TypedReferenceCount
static TypeHandle | get_class_type ()
static void | init_type ()
Static Public Member Functions inherited from TypedObject
static TypeHandle | get_class_type ()
static void | init_type ()
| This function is declared non-inline to work around a compiler bug in g++ 2.96. More...
Static Public Member Functions inherited from ReferenceCount
static TypeHandle | get_class_type ()
static void | init_type ()

## Friends
class | VirtualFileSystem

## Additional Inherited Members
Public Attributes inherited from TypedObject
| get_type
Public Attributes inherited from ReferenceCount
| get_ref_count
| Returns the current reference count. More...

## Detailed Description

The abstract base class for a mount definition used within a VirtualFileSystem.

Normally users don't need to monkey with this class directly.

Definition at line 31 of file virtualFileMount.h.

## Member Function Documentation

## ◆ atomic_compare_and_exchange_contents()

bool VirtualFileMount::atomic_compare_and_exchange_contents | ( | const Filename & | file,
|  | std::string & | orig_contents,
|  | const std::string & | old_contents,
|  | const std::string & | new_contents
| ) |  |
| virtual

See Filename::atomic_compare_and_exchange_contents().

Reimplemented in VirtualFileMountSystem, and VirtualFileMountRamdisk.

Definition at line 316 of file virtualFileMount.cxx.

Referenced by VirtualFileSimple::atomic_compare_and_exchange_contents().

## ◆ atomic_read_contents()

bool VirtualFileMount::atomic_read_contents | ( | const Filename & | file,
|  | std::string & | contents
| ) |  | const
| virtual

See Filename::atomic_read_contents().

Reimplemented in VirtualFileMountSystem, and VirtualFileMountRamdisk.

Definition at line 326 of file virtualFileMount.cxx.

Referenced by VirtualFileSimple::atomic_read_contents().

## ◆ close_read_file()

void VirtualFileMount::close_read_file | ( | std::istream * | stream | ) | const
| virtual

Closes a file opened by a previous call to open_read_file().

This really just deletes the istream pointer, but it is recommended to use this interface instead of deleting it explicitly, to help work around compiler issues.

Definition at line 212 of file virtualFileMount.cxx.

References VirtualFileSystem::close_read_file().

Referenced by VirtualFileSimple::close_read_file().

## ◆ close_read_write_file()

void VirtualFileMount::close_read_write_file | ( | std::iostream * | stream | ) |
| virtual

Closes a file opened by a previous call to open_read_write_file().

This really just deletes the iostream pointer, but it is recommended to use this interface instead of deleting it explicitly, to help work around compiler issues.

Definition at line 296 of file virtualFileMount.cxx.

References VirtualFileSystem::close_read_write_file().

Referenced by VirtualFileSimple::close_read_write_file().

## ◆ close_write_file()

void VirtualFileMount::close_write_file | ( | std::ostream * | stream | ) |
| virtual

Closes a file opened by a previous call to open_write_file().

This really just deletes the ostream pointer, but it is recommended to use this interface instead of deleting it explicitly, to help work around compiler issues.

Definition at line 265 of file virtualFileMount.cxx.

References VirtualFileSystem::close_write_file().

Referenced by VirtualFileSimple::close_write_file().

## ◆ copy_file()

bool VirtualFileMount::copy_file | ( | const Filename & | orig_filename,
|  | const Filename & | new_filename
| ) |  |
| virtual

Attempts to copy the contents of the indicated file to the indicated file.

Both filenames will be within the mount. Returns true on success, false on failure. If this returns false, the copy will be performed by explicit read-and-write operations.

Reimplemented in VirtualFileMountSystem, and VirtualFileMountRamdisk.

Definition at line 101 of file virtualFileMount.cxx.

## ◆ create_file()

bool VirtualFileMount::create_file | ( | const Filename & | file | ) |
| virtual

Attempts to create the indicated file within the mount, if it does not already exist.

Returns true on success (or if the file already exists), or false if it cannot be created.

Reimplemented in VirtualFileMountSystem, and VirtualFileMountRamdisk.

Definition at line 69 of file virtualFileMount.cxx.

## ◆ delete_file()

bool VirtualFileMount::delete_file | ( | const Filename & | file | ) |
| virtual

Attempts to delete the indicated file or directory within the mount.

This can remove a single file or an empty directory. It will not remove a nonempty directory. Returns true on success, false on failure.

Reimplemented in VirtualFileMountSystem, and VirtualFileMountRamdisk.

Definition at line 79 of file virtualFileMount.cxx.

Referenced by VirtualFileSimple::delete_file().

## ◆ get_file_system()

VirtualFileSystem * VirtualFileMount::get_file_system | ( |  | ) | const
| inline

Returns the file system this mount object is attached to.

Definition at line 27 of file virtualFileMount.I.

Referenced by VirtualFileSimple::get_file_system().

## ◆ get_mount_flags()

int VirtualFileMount::get_mount_flags | ( |  | ) | const
| inline

Returns the set of flags passed by the user to the VirtualFileSystem::mount() command.

Definition at line 46 of file virtualFileMount.I.

## ◆ get_mount_point()

const Filename & VirtualFileMount::get_mount_point | ( |  | ) | const
| inline

Returns the name of the directory within the virtual file system that this mount object is attached to.

This directory name will end with a slash.

Definition at line 37 of file virtualFileMount.I.

Referenced by VirtualFileSimple::get_filename().

## ◆ get_system_info()

bool VirtualFileMount::get_system_info | ( | const Filename & | file,
|  | SubfileInfo & | info
| ) |  |
| virtual

Populates the SubfileInfo structure with the data representing where the file actually resides on disk, if this is knowable.

Returns true if the file might reside on disk, and the info is populated, or false if it does not (or it is not known where the file resides), in which case the info is meaningless.

Reimplemented in VirtualFileMountSystem, and VirtualFileMountMultifile.

Definition at line 308 of file virtualFileMount.cxx.

## ◆ is_writable()

bool VirtualFileMount::is_writable | ( | const Filename & | file | ) | const
| virtual

Returns true if the named file or directory may be written to, false otherwise.

Reimplemented in VirtualFileMountSystem, and VirtualFileMountRamdisk.

Definition at line 121 of file virtualFileMount.cxx.

Referenced by VirtualFileSimple::is_writable().

## ◆ make_directory()

bool VirtualFileMount::make_directory | ( | const Filename & | file | ) |
| virtual

Attempts to create the indicated file within the mount, if it does not already exist.

Returns true on success, or false if it cannot be created. If the directory already existed prior to this call, may return either true or false.

Reimplemented in VirtualFileMountSystem, and VirtualFileMountRamdisk.

Definition at line 112 of file virtualFileMount.cxx.

## ◆ make_virtual_file()

PointerTo< VirtualFile > VirtualFileMount::make_virtual_file | ( | const Filename & | local_filename,
|  | const Filename & | original_filename,
|  | bool | implicit_pz_file,
|  | int | open_flags
| ) |  |
| virtual

Constructs and returns a new VirtualFile instance that corresponds to the indicated filename within this mount point.

The returned VirtualFile object does not imply that the given file actually exists; but if the file does exist, then the handle can be used to read it.

Definition at line 41 of file virtualFileMount.cxx.

## ◆ open_append_file()

ostream * VirtualFileMount::open_append_file | ( | const Filename & | file | ) |
| virtual

Works like open_write_file(), but the file is opened in append mode.

Like open_write_file, the returned pointer should eventually be passed to close_write_file().

Reimplemented in VirtualFileMountSystem, and VirtualFileMountRamdisk.

Definition at line 254 of file virtualFileMount.cxx.

Referenced by VirtualFileSimple::open_append_file().

## ◆ open_read_append_file()

iostream * VirtualFileMount::open_read_append_file | ( | const Filename & | file | ) |
| virtual

Works like open_read_write_file(), but the file is opened in append mode.

Like open_read_write_file, the returned pointer should eventually be passed to close_read_write_file().

Reimplemented in VirtualFileMountSystem, and VirtualFileMountRamdisk.

Definition at line 285 of file virtualFileMount.cxx.

Referenced by VirtualFileSimple::open_read_append_file().

## ◆ open_read_file()

istream * VirtualFileMount::open_read_file | ( | const Filename & | file,
|  | bool | do_uncompress
| ) |  | const

Opens the file for reading.

Returns a newly allocated istream on success (which you should eventually delete when you are done reading). Returns NULL on failure.

If do_uncompress is true, the file is also decompressed on-the-fly using zlib.

Definition at line 191 of file virtualFileMount.cxx.

## ◆ open_read_write_file()

iostream * VirtualFileMount::open_read_write_file | ( | const Filename & | file,
|  | bool | truncate
| ) |  |
| virtual

Opens the file for writing.

Returns a newly allocated iostream on success (which you should eventually delete when you are done writing). Returns NULL on failure.

Reimplemented in VirtualFileMountSystem, and VirtualFileMountRamdisk.

Definition at line 275 of file virtualFileMount.cxx.

Referenced by VirtualFileSimple::open_read_write_file().

## ◆ open_write_file() [1/2]

ostream * VirtualFileMount::open_write_file | ( | const Filename & | file,
|  | bool | do_compress,
|  | bool | truncate
| ) |  |

Opens the file for writing.

Returns a newly allocated ostream on success (which you should eventually delete when you are done writing). Returns NULL on failure.

If do_compress is true, the file is also compressed on-the-fly using zlib.

Definition at line 234 of file virtualFileMount.cxx.

References open_write_file().

## ◆ open_write_file() [2/2]

ostream * VirtualFileMount::open_write_file | ( | const Filename & | file,
|  | bool | truncate
| ) |  |
| virtual

Opens the file for writing.

Returns a newly allocated ostream on success (which you should eventually delete when you are done writing). Returns NULL on failure.

Reimplemented in VirtualFileMountSystem, and VirtualFileMountRamdisk.

Definition at line 222 of file virtualFileMount.cxx.

Referenced by VirtualFileSimple::open_write_file(), and open_write_file().

## ◆ read_file()

bool VirtualFileMount::read_file | ( | const Filename & | file,
|  | bool | do_uncompress,
|  | vector_uchar & | result
| ) |  | const
| virtual

Fills up the indicated pvector with the contents of the file, if it is a regular file.

Returns true on success, false otherwise.

Reimplemented in VirtualFileMountMultifile.

Definition at line 130 of file virtualFileMount.cxx.

## ◆ rename_file()

bool VirtualFileMount::rename_file | ( | const Filename & | orig_filename,
|  | const Filename & | new_filename
| ) |  |
| virtual

Attempts to rename the contents of the indicated file to the indicated file.

Both filenames will be within the mount. Returns true on success, false on failure. If this returns false, this will be attempted again with a copy-and-delete operation.

Reimplemented in VirtualFileMountSystem, and VirtualFileMountRamdisk.

Definition at line 90 of file virtualFileMount.cxx.

## ◆ write_file()

bool VirtualFileMount::write_file | ( | const Filename & | file,
|  | bool | do_compress,
|  | const unsigned char * | data,
|  | size_t | data_size
| ) |  |
| virtual

Writes the indicated data to the file, if it is a writable file.

Returns true on success, false otherwise.

Definition at line 162 of file virtualFileMount.cxx.

The documentation for this class was generated from the following files:

- panda/src/express/virtualFileMount.h
- panda/src/express/virtualFileMount.cxx
- panda/src/express/virtualFileMount.I