Panda3D
|
A simple file or directory within the VirtualFileSystem: this maps to exactly one file on one mount point. More...
#include "virtualFileSimple.h"
Public Member Functions | |
VirtualFileSimple (VirtualFileMount *mount, const Filename &local_filename, bool implicit_pz_file) | |
virtual TypeHandle | force_init_type () |
virtual off_t | get_file_size (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 |
Returns the current size on disk (or wherever it is) of the file before it has been opened. | |
virtual VirtualFileSystem * | get_file_system () const |
Returns the VirtualFileSystem this file is associated with. | |
virtual Filename | get_filename () const |
Returns the full pathname to this file within the virtual file system. | |
VirtualFileMount * | get_mount () const |
Returns the VirtualFileMount this file is associated with. | |
virtual time_t | get_timestamp () 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 |
Returns true if this file exists, false otherwise. | |
virtual bool | is_directory () const |
Returns true if this file represents a directory (and scan_directory() may be called), false otherwise. | |
bool | is_implicit_pz_file () const |
Returns true if this file is a .pz file that should be implicitly decompressed on load, or false if it is not a .pz file or if it should not be decompressed. | |
virtual bool | is_regular_file () const |
Returns true if this file represents a regular file (and read_file() may be called), false otherwise. | |
virtual istream * | open_read_file (bool auto_unwrap) const |
Opens the file for reading. | |
virtual bool | read_file (pvector< unsigned char > &result, bool auto_unwrap) const |
Fills up the indicated pvector with the contents of the file, if it is a regular file. | |
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. | |
Protected Member Functions | |
virtual bool | scan_local_directory (VirtualFileList *file_list, const ov_set< string > &mount_points) const |
Fills file_list up with the list of files that are within this directory, excluding those whose basenames are listed in mount_points. |
A simple file or directory within the VirtualFileSystem: this maps to exactly one file on one mount point.
Most directories, and all regular files, are of this kind.
Definition at line 29 of file virtualFileSimple.h.
off_t VirtualFileSimple::get_file_size | ( | ) | const [virtual] |
Returns the current size on disk (or wherever it is) of the file before it has been opened.
Reimplemented from VirtualFile.
Definition at line 140 of file virtualFileSimple.cxx.
off_t VirtualFileSimple::get_file_size | ( | 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.
Reimplemented from VirtualFile.
Definition at line 129 of file virtualFileSimple.cxx.
VirtualFileSystem * VirtualFileSimple::get_file_system | ( | ) | const [virtual] |
Returns the VirtualFileSystem this file is associated with.
Implements VirtualFile.
Definition at line 29 of file virtualFileSimple.cxx.
References VirtualFileMount::get_file_system().
Filename VirtualFileSimple::get_filename | ( | ) | const [virtual] |
Returns the full pathname to this file within the virtual file system.
Implements VirtualFile.
Definition at line 40 of file virtualFileSimple.cxx.
References Filename::get_fullpath(), and VirtualFileMount::get_mount_point().
VirtualFileMount * VirtualFileSimple::get_mount | ( | ) | const [inline] |
Returns the VirtualFileMount this file is associated with.
Definition at line 37 of file virtualFileSimple.I.
time_t VirtualFileSimple::get_timestamp | ( | ) | 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.
Reimplemented from VirtualFile.
Definition at line 159 of file virtualFileSimple.cxx.
bool VirtualFileSimple::has_file | ( | ) | const [virtual] |
Returns true if this file exists, false otherwise.
Reimplemented from VirtualFile.
Definition at line 64 of file virtualFileSimple.cxx.
static void VirtualFileSimple::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 VirtualFile.
Definition at line 74 of file virtualFileSimple.h.
References VirtualFile::init_type().
bool VirtualFileSimple::is_directory | ( | ) | const [virtual] |
Returns true if this file represents a directory (and scan_directory() may be called), false otherwise.
Reimplemented from VirtualFile.
Definition at line 75 of file virtualFileSimple.cxx.
bool VirtualFileSimple::is_implicit_pz_file | ( | ) | const [inline] |
Returns true if this file is a .pz file that should be implicitly decompressed on load, or false if it is not a .pz file or if it should not be decompressed.
Definition at line 49 of file virtualFileSimple.I.
bool VirtualFileSimple::is_regular_file | ( | ) | const [virtual] |
Returns true if this file represents a regular file (and read_file() may be called), false otherwise.
Reimplemented from VirtualFile.
Definition at line 86 of file virtualFileSimple.cxx.
istream * VirtualFileSimple::open_read_file | ( | bool | auto_unwrap | ) | const [virtual] |
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 auto_unwrap is true, an explicitly-named .pz file is automatically decompressed and the decompressed contents are returned. This is different than vfs-implicit-pz, which will automatically decompress a file if the extension .pz is *not* given.
Reimplemented from VirtualFile.
Definition at line 105 of file virtualFileSimple.cxx.
References Filename::get_extension(), and Filename::set_binary().
bool VirtualFileSimple::read_file | ( | pvector< unsigned char > & | result, |
bool | auto_unwrap | ||
) | 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 from VirtualFile.
Definition at line 171 of file virtualFileSimple.cxx.
References Filename::get_extension(), VirtualFileMount::read_file(), and Filename::set_binary().
bool VirtualFileSimple::scan_local_directory | ( | VirtualFileList * | file_list, |
const ov_set< string > & | mount_points | ||
) | const [protected, virtual] |
Fills file_list up with the list of files that are within this directory, excluding those whose basenames are listed in mount_points.
Returns true if successful, false if the file is not a directory or the directory cannot be read.
Reimplemented from VirtualFile.
Definition at line 195 of file virtualFileSimple.cxx.
References VirtualFileList::add_file(), and ordered_vector< Key, Compare >::end().