#include <virtualFileSystem.h>
Public Types | |
enum | MountFlags { MF_owns_pointer = 0x0001, MF_read_only = 0x0002 } |
Public Member Functions | |
VirtualFileSystem () | |
~VirtualFileSystem () | |
bool | mount (Multifile *multifile, const string &mount_point, int flags) |
Mounts the indicated Multifile at the given mount point. | |
bool | mount (const Filename &physical_filename, const string &mount_point, int flags) |
Mounts the indicated system file or directory at the given mount point. | |
int | unmount (Multifile *multifile) |
Unmounts all appearances of the indicated Multifile from the file system. | |
int | unmount (const Filename &physical_filename) |
Unmounts all appearances of the indicated physical filename (either a directory name or a Multifile name) from the file system. | |
int | unmount_point (const string &mount_point) |
Unmounts all systems attached to the given mount point from the file system. | |
int | unmount_all () |
Unmounts all files from the file system. | |
bool | chdir (const string &new_directory) |
Changes the current directory. | |
const Filename & | get_cwd () const |
Returns the current directory name. | |
PointerTo< VirtualFile > | get_file (const Filename &filename) const |
Looks up the file by the indicated name in the file system. | |
PointerTo< VirtualFile > | find_file (const Filename &filename, const DSearchPath &searchpath) const |
Uses the indicated search path to find the file within the file system. | |
bool | resolve_filename (Filename &filename, const DSearchPath &searchpath, const string &default_extension=string()) const |
Searches the given search path for the filename. | |
int | find_all_files (const Filename &filename, const DSearchPath &searchpath, DSearchPath::Results &results) const |
Searches all the directories in the search list for the indicated file, in order. | |
bool | exists (const Filename &filename) const |
Convenience function; returns true if the named file exists. | |
bool | is_directory (const Filename &filename) const |
Convenience function; returns true if the named file exists and is a directory. | |
bool | is_regular_file (const Filename &filename) const |
Convenience function; returns true if the named file exists and is a regular file. | |
void | ls (const string &filename) const |
Convenience function; lists the files within the indicated directory. | |
void | ls_all (const string &filename) const |
Convenience function; lists the files within the indicated directory, and all files below, recursively. | |
void | write (ostream &out) const |
string | read_file (const Filename &filename) const |
Convenience function; returns the entire contents of the indicated file as a string. | |
istream * | open_read_file (const Filename &filename) const |
Convenience function; returns a newly allocated istream if the file exists and can be read, or NULL otherwise. | |
bool | read_file (const Filename &filename, string &result) const |
Convenience function; fills the string up with the data from the indicated file, if it exists and can be read. | |
void | scan_mount_points (vector_string &names, const Filename &path) const |
Adds to names a list of all the mount points in use that are one directory below path, if any. | |
Static Public Member Functions | |
VirtualFileSystem * | get_global_ptr () |
Returns the default global VirtualFileSystem. | |
Private Types | |
typedef pvector< VirtualFileMount * > | Mounts |
Private Member Functions | |
Filename | normalize_mount_point (const string &mount_point) const |
Converts the mount point string supplied by the user to standard form (relative to the current directory, with no double slashes, and not terminating with a slash). | |
bool | found_match (PointerTo< VirtualFile > &found_file, VirtualFileComposite *&composite_file, VirtualFileMount *mount, const string &local_filename) const |
Evaluates one match found during a get_file() operation. | |
Private Attributes | |
Mounts | _mounts |
Filename | _cwd |
Static Private Attributes | |
VirtualFileSystem * | _global_ptr = NULL |
For instance, a VirtualFileSystem can transparently mount one or more Multifiles as their own subdirectory hierarchies.
Definition at line 59 of file virtualFileSystem.h.
|
Definition at line 111 of file virtualFileSystem.h. |
|
Definition at line 64 of file virtualFileSystem.h. |
|
Definition at line 44 of file virtualFileSystem.cxx. References unmount_all(). |
|
Definition at line 57 of file virtualFileSystem.cxx. References _mounts, mount(), and normalize_mount_point(). |
|
Changes the current directory. This is used to resolve relative pathnames in get_file() and/or find_file(). Returns true if successful, false otherwise. This accepts a string rather than a Filename simply for programmer convenience from the Python prompt. Definition at line 306 of file virtualFileSystem.cxx. |
|
Convenience function; returns true if the named file exists.
Definition at line 34 of file virtualFileSystem.I. References get_file(), INLINE, NULL, and PT. Referenced by BamFile::~BamFile(). |
|
Searches all the directories in the search list for the indicated file, in order. Fills up the results list with *all* of the matching filenames found, if any. Returns the number of matches found. It is the responsibility of the the caller to clear the results list first; otherwise, the newly-found files will be appended to the list. Definition at line 519 of file virtualFileSystem.cxx. References size_t. |
|
Uses the indicated search path to find the file within the file system. Returns the first occurrence of the file found, or NULL if the file cannot be found. Definition at line 412 of file virtualFileSystem.cxx. |
|
Evaluates one match found during a get_file() operation. There may be multiple matches for a particular filename due to the ambiguities introduced by allowing multiple mount points, so we may have to keep searching even after the first match is found. Returns true if the search should terminate now, or false if it should keep iterating. Definition at line 764 of file virtualFileSystem.cxx. |
|
Returns the current directory name. See chdir(). Definition at line 330 of file virtualFileSystem.cxx. |
|
Looks up the file by the indicated name in the file system. Returns a VirtualFile pointer representing the file if it is found, or NULL if it is not. Definition at line 347 of file virtualFileSystem.cxx. Referenced by exists(), is_directory(), ls_all(), read_file(), and unmount_point(). |
|
Returns the default global VirtualFileSystem. You may create your own personal VirtualFileSystem objects and use them for whatever you like, but Panda will attempt to load models and stuff from this default object. Initially, the global VirtualFileSystem is set up to mount the OS filesystem to root; i.e. it is equivalent to the OS filesystem. This may be subsequently adjusted by the user. Definition at line 592 of file virtualFileSystem.cxx. Referenced by load_chancfg_database(), TexturePool::ns_has_texture(), and BamFile::~BamFile(). |
|
Convenience function; returns true if the named file exists and is a directory.
Definition at line 49 of file virtualFileSystem.I. References get_file(), INLINE, NULL, and PT. |
|
Convenience function; returns true if the named file exists and is a regular file.
Definition at line 65 of file virtualFileSystem.I. References NULL. |
|
Convenience function; lists the files within the indicated directory. This accepts a string instead of a Filename purely for programmer convenience at the Python prompt. Definition at line 85 of file virtualFileSystem.I. References NULL. |
|
Convenience function; lists the files within the indicated directory, and all files below, recursively. This accepts a string instead of a Filename purely for programmer convenience at the Python prompt. Definition at line 112 of file virtualFileSystem.I. References get_file(), INLINE, NULL, and PT. |
|
Mounts the indicated system file or directory at the given mount point. If the named file is a directory, mounts the directory. If the named file is a Multifile, mounts it as a Multifile. Returns true on success, false on failure. A given system directory may be mounted to multiple different mount point, and the same mount point may share multiple system directories. In the case of ambiguities, the most-recently mounted system wins. Definition at line 112 of file virtualFileSystem.cxx. |
|
Mounts the indicated Multifile at the given mount point. If flags contains MF_owns_pointer, the Multifile will be deleted when it is eventually unmounted. Definition at line 76 of file virtualFileSystem.cxx. References _mounts, Filename::exists(), Filename::is_directory(), MF_owns_pointer, MF_read_only, mount(), normalize_mount_point(), and Multifile::open_read(). Referenced by mount(), unmount(), and ~VirtualFileSystem(). |
|
Converts the mount point string supplied by the user to standard form (relative to the current directory, with no double slashes, and not terminating with a slash). The initial slash is removed. Definition at line 731 of file virtualFileSystem.cxx. Referenced by mount(), and ~VirtualFileSystem(). |
|
Convenience function; returns a newly allocated istream if the file exists and can be read, or NULL otherwise. Does not return an invalid istream. Definition at line 153 of file virtualFileSystem.I. Referenced by load_chancfg_database(). |
|
Convenience function; fills the string up with the data from the indicated file, if it exists and can be read. Returns true on success, false otherwise. Definition at line 179 of file virtualFileSystem.I. |
|
Convenience function; returns the entire contents of the indicated file as a string.
Definition at line 133 of file virtualFileSystem.I. References get_file(), INLINE, NULL, and PT. |
|
Searches the given search path for the filename. If it is found, updates the filename to the full pathname found and returns true; otherwise, returns false. Definition at line 454 of file virtualFileSystem.cxx. Referenced by load_chancfg_database(), and TexturePool::ns_has_texture(). |
|
Adds to names a list of all the mount points in use that are one directory below path, if any. That is, these are the external files or directories mounted directly to the indicated path. The names vector is filled with a set of basenames, the basename part of the mount point. Definition at line 684 of file virtualFileSystem.cxx. Referenced by VirtualFile::is_regular_file(). |
|
Unmounts all appearances of the indicated physical filename (either a directory name or a Multifile name) from the file system. Returns the number of appearances unmounted. Definition at line 204 of file virtualFileSystem.cxx. |
|
Unmounts all appearances of the indicated Multifile from the file system. Returns the number of appearances unmounted. Definition at line 160 of file virtualFileSystem.cxx. |
|
Unmounts all files from the file system. Returns the number of systems unmounted. Definition at line 273 of file virtualFileSystem.cxx. Referenced by VirtualFileSystem(). |
|
Unmounts all systems attached to the given mount point from the file system. Returns the number of appearances unmounted. Definition at line 239 of file virtualFileSystem.cxx. References _cwd, get_file(), NULL, and PT. |
|
Definition at line 556 of file virtualFileSystem.cxx. |
|
Definition at line 113 of file virtualFileSystem.h. Referenced by unmount_point(). |
|
Definition at line 32 of file virtualFileSystem.cxx. |
|
Definition at line 112 of file virtualFileSystem.h. Referenced by mount(), unmount(), and ~VirtualFileSystem(). |