Panda3D
|
Simulates an actual directory on disk with in-memory storage. More...
#include "virtualFileMountRamdisk.h"
Classes | |
class | Directory |
class | File |
class | FileBase |
Public Member Functions | |
virtual bool | atomic_compare_and_exchange_contents (const Filename &file, string &orig_contents, const string &old_contents, const string &new_contents) |
See Filename::atomic_compare_and_exchange_contents(). | |
virtual bool | atomic_read_contents (const Filename &file, string &contents) const |
See Filename::atomic_read_contents(). | |
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. | |
virtual bool | create_file (const Filename &file) |
Attempts to create the indicated file within the mount, if it does not already exist. | |
virtual bool | delete_file (const Filename &file) |
Attempts to delete the indicated file or directory within the mount. | |
virtual TypeHandle | force_init_type () |
virtual off_t | get_file_size (const Filename &file, istream *stream) const |
Returns the current size on disk (or wherever it is) of the already-open file. | |
virtual off_t | get_file_size (const Filename &file) const |
Returns the current size on disk (or wherever it is) of the file before it has been opened. | |
virtual time_t | get_timestamp (const Filename &file) const |
Returns a time_t value that represents the time the file was last modified, to within whatever precision the operating system records this information (on a Windows95 system, for instance, this may only be accurate to within 2 seconds). | |
virtual TypeHandle | get_type () const |
virtual bool | has_file (const Filename &file) const |
Returns true if the indicated file exists within the mount system. | |
virtual bool | is_directory (const Filename &file) const |
Returns true if the indicated file exists within the mount system and is a directory. | |
virtual bool | is_regular_file (const Filename &file) const |
Returns true if the indicated file exists within the mount system and is a regular file. | |
virtual bool | is_writable (const Filename &file) const |
Returns true if the named file or directory may be written to, false otherwise. | |
virtual bool | make_directory (const Filename &file) |
Attempts to create the indicated file within the mount, if it does not already exist. | |
virtual ostream * | open_append_file (const Filename &file) |
Works like open_write_file(), but the file is opened in append mode. | |
virtual iostream * | open_read_append_file (const Filename &file) |
Works like open_read_write_file(), but the file is opened in append mode. | |
virtual istream * | open_read_file (const Filename &file) const |
Opens the file for reading, if it exists. | |
virtual iostream * | open_read_write_file (const Filename &file, bool truncate) |
Opens the file for writing. | |
virtual ostream * | open_write_file (const Filename &file, bool truncate) |
Opens the file for writing. | |
virtual void | output (ostream &out) const |
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. | |
virtual bool | scan_directory (vector_string &contents, const Filename &dir) const |
Fills the given vector up with the list of filenames that are local to this directory, if the filename is a directory. | |
Static Public Member Functions | |
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. |
Simulates an actual directory on disk with in-memory storage.
This is useful mainly for performing high level functions that expect disk I/O without actually writing files to disk. Naturally, there are significant limits to the size of the files that may be written with this system; and "files" written here are not automatically persistent between sessions.
Definition at line 34 of file virtualFileMountRamdisk.h.
bool VirtualFileMountRamdisk::atomic_compare_and_exchange_contents | ( | const Filename & | file, |
string & | orig_contents, | ||
const string & | old_contents, | ||
const string & | new_contents | ||
) | [virtual] |
See Filename::atomic_compare_and_exchange_contents().
Reimplemented from VirtualFileMount.
Definition at line 428 of file virtualFileMountRamdisk.cxx.
bool VirtualFileMountRamdisk::atomic_read_contents | ( | const Filename & | file, |
string & | contents | ||
) | const [virtual] |
See Filename::atomic_read_contents().
Reimplemented from VirtualFileMount.
Definition at line 456 of file virtualFileMountRamdisk.cxx.
bool VirtualFileMountRamdisk::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 from VirtualFileMount.
Definition at line 148 of file virtualFileMountRamdisk.cxx.
bool VirtualFileMountRamdisk::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 from VirtualFileMount.
Definition at line 56 of file virtualFileMountRamdisk.cxx.
bool VirtualFileMountRamdisk::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 from VirtualFileMount.
Definition at line 73 of file virtualFileMountRamdisk.cxx.
off_t VirtualFileMountRamdisk::get_file_size | ( | const Filename & | file | ) | const [virtual] |
Returns the current size on disk (or wherever it is) of the file before it has been opened.
Implements VirtualFileMount.
Definition at line 367 of file virtualFileMountRamdisk.cxx.
off_t VirtualFileMountRamdisk::get_file_size | ( | const Filename & | file, |
istream * | stream | ||
) | const [virtual] |
Returns the current size on disk (or wherever it is) of the already-open file.
Pass in the stream that was returned by open_read_file(); some implementations may require this stream to determine the size.
Implements VirtualFileMount.
Definition at line 348 of file virtualFileMountRamdisk.cxx.
time_t VirtualFileMountRamdisk::get_timestamp | ( | const Filename & | file | ) | const [virtual] |
Returns a time_t value that represents the time the file was last modified, to within whatever precision the operating system records this information (on a Windows95 system, for instance, this may only be accurate to within 2 seconds).
If the timestamp cannot be determined, either because it is not supported by the operating system or because there is some error (such as file not found), returns 0.
Implements VirtualFileMount.
Definition at line 394 of file virtualFileMountRamdisk.cxx.
bool VirtualFileMountRamdisk::has_file | ( | const Filename & | file | ) | const [virtual] |
Returns true if the indicated file exists within the mount system.
Implements VirtualFileMount.
Definition at line 40 of file virtualFileMountRamdisk.cxx.
Referenced by is_writable().
static void VirtualFileMountRamdisk::init_type | ( | ) | [inline, static] |
This function is declared non-inline to work around a compiler bug in g++ 2.96.
Making it inline seems to cause problems in the optimizer.
Reimplemented from VirtualFileMount.
Definition at line 171 of file virtualFileMountRamdisk.h.
References VirtualFileMount::init_type().
bool VirtualFileMountRamdisk::is_directory | ( | const Filename & | file | ) | const [virtual] |
Returns true if the indicated file exists within the mount system and is a directory.
Implements VirtualFileMount.
Definition at line 199 of file virtualFileMountRamdisk.cxx.
bool VirtualFileMountRamdisk::is_regular_file | ( | const Filename & | file | ) | const [virtual] |
Returns true if the indicated file exists within the mount system and is a regular file.
Implements VirtualFileMount.
Definition at line 213 of file virtualFileMountRamdisk.cxx.
bool VirtualFileMountRamdisk::is_writable | ( | const Filename & | file | ) | const [virtual] |
Returns true if the named file or directory may be written to, false otherwise.
Reimplemented from VirtualFileMount.
Definition at line 227 of file virtualFileMountRamdisk.cxx.
References has_file().
bool VirtualFileMountRamdisk::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 from VirtualFileMount.
Definition at line 185 of file virtualFileMountRamdisk.cxx.
ostream * VirtualFileMountRamdisk::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 from VirtualFileMount.
Definition at line 286 of file virtualFileMountRamdisk.cxx.
iostream * VirtualFileMountRamdisk::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 from VirtualFileMount.
Definition at line 326 of file virtualFileMountRamdisk.cxx.
istream * VirtualFileMountRamdisk::open_read_file | ( | const Filename & | file | ) | const [virtual] |
Opens the file for reading, if it exists.
Returns a newly allocated istream on success (which you should eventually delete when you are done reading). Returns NULL on failure.
Implements VirtualFileMount.
Definition at line 240 of file virtualFileMountRamdisk.cxx.
iostream * VirtualFileMountRamdisk::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 from VirtualFileMount.
Definition at line 306 of file virtualFileMountRamdisk.cxx.
ostream * VirtualFileMountRamdisk::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 from VirtualFileMount.
Definition at line 261 of file virtualFileMountRamdisk.cxx.
bool VirtualFileMountRamdisk::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 from VirtualFileMount.
Definition at line 90 of file virtualFileMountRamdisk.cxx.
bool VirtualFileMountRamdisk::scan_directory | ( | vector_string & | contents, |
const Filename & | dir | ||
) | const [virtual] |
Fills the given vector up with the list of filenames that are local to this directory, if the filename is a directory.
Returns true if successful, or false if the file is not a directory or cannot be read.
Implements VirtualFileMount.
Definition at line 407 of file virtualFileMountRamdisk.cxx.