VirtualFileSystem
from panda3d.core import VirtualFileSystem
- class VirtualFileSystem
Bases:
DTOOL_SUPER_BASE
A hierarchy of directories and files that appears to be one continuous file system, even though the files may originate from several different sources that may not be related to the actual OS’s file system.
For instance, a VirtualFileSystem can transparently mount one or more Multifiles as their own subdirectory hierarchies.
Inheritance diagram
- MFReadOnly = 2
- MF_read_only = 2
- __init__(*args, **kwargs)
- chdir()
C++ Interface: chdir(const VirtualFileSystem self, const Filename new_directory)
- /**
Changes the current directory. This is used to resolve relative pathnames
in get_file() and/or find_file(). Returns true if successful, false
otherwise.
*/
- closeReadFile()
C++ Interface: close_read_file(istream stream)
- /**
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.
*/
- closeReadWriteFile()
C++ Interface: close_read_write_file(iostream stream)
- /**
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.
*/
- closeWriteFile()
C++ Interface: close_write_file(ostream stream)
- /**
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.
*/
- close_read_file()
C++ Interface: close_read_file(istream stream)
- /**
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.
*/
- close_read_write_file()
C++ Interface: close_read_write_file(iostream stream)
- /**
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.
*/
- close_write_file()
C++ Interface: close_write_file(ostream stream)
- /**
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.
*/
- copyFile()
C++ Interface: copy_file(const VirtualFileSystem self, const Filename orig_filename, const Filename new_filename)
- /**
Attempts to copy the contents of the indicated file to the indicated file.
Returns true on success, false on failure.
*/
- copy_file()
C++ Interface: copy_file(const VirtualFileSystem self, const Filename orig_filename, const Filename new_filename)
- /**
Attempts to copy the contents of the indicated file to the indicated file.
Returns true on success, false on failure.
*/
- createFile()
C++ Interface: create_file(const VirtualFileSystem self, const Filename filename)
- /**
Attempts to create a file by the indicated name in the filesystem, if
possible, and returns it. If a file by this name already exists, returns
the same thing as get_file(). If the filename is located within a read-
only directory, or the directory doesn’t exist, returns NULL.
*/
- create_file()
C++ Interface: create_file(const VirtualFileSystem self, const Filename filename)
- /**
Attempts to create a file by the indicated name in the filesystem, if
possible, and returns it. If a file by this name already exists, returns
the same thing as get_file(). If the filename is located within a read-
only directory, or the directory doesn’t exist, returns NULL.
*/
- deleteFile()
C++ Interface: delete_file(const VirtualFileSystem self, const Filename filename)
- /**
Attempts to delete the indicated file or directory. This can remove a
single file or an empty directory. It will not remove a nonempty
directory. Returns true on success, false on failure.
*/
- delete_file()
C++ Interface: delete_file(const VirtualFileSystem self, const Filename filename)
- /**
Attempts to delete the indicated file or directory. This can remove a
single file or an empty directory. It will not remove a nonempty
directory. Returns true on success, false on failure.
*/
- exists()
C++ Interface: exists(VirtualFileSystem self, const Filename filename)
- /**
Convenience function; returns true if the named file exists in the virtual
file system hierarchy.
*/
- findAllFiles()
C++ Interface: find_all_files(VirtualFileSystem self, const Filename filename, const DSearchPath searchpath, Results results)
- /**
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.
*/
- findFile()
C++ Interface: find_file(VirtualFileSystem self, const Filename filename, const DSearchPath searchpath, bool status_only)
- /**
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.
*/
- find_all_files()
C++ Interface: find_all_files(VirtualFileSystem self, const Filename filename, const DSearchPath searchpath, Results results)
- /**
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.
*/
- find_file()
C++ Interface: find_file(VirtualFileSystem self, const Filename filename, const DSearchPath searchpath, bool status_only)
- /**
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.
*/
- getCwd()
C++ Interface: get_cwd(VirtualFileSystem self)
- /**
Returns the current directory name. See chdir().
*/
- getFile()
C++ Interface: get_file(VirtualFileSystem self, const Filename filename, bool status_only)
- /**
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.
If status_only is true, the file will be checked for existence and length
and so on, but the returned file’s contents cannot be read. This is an
optimization which is especially important for certain mount types, for
instance HTTP, for which opening a file to determine its status is
substantially less expensive than opening it to read its contents.
*/
- getGlobalPtr()
C++ Interface: get_global_ptr()
- /**
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.
*/
- getMount()
C++ Interface: get_mount(VirtualFileSystem self, int n)
- /**
Returns the nth mount in the system.
*/
- getMounts()
- getNumMounts()
C++ Interface: get_num_mounts(VirtualFileSystem self)
- /**
Returns the number of individual mounts in the system.
*/
- get_cwd()
C++ Interface: get_cwd(VirtualFileSystem self)
- /**
Returns the current directory name. See chdir().
*/
- get_file()
C++ Interface: get_file(VirtualFileSystem self, const Filename filename, bool status_only)
- /**
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.
If status_only is true, the file will be checked for existence and length
and so on, but the returned file’s contents cannot be read. This is an
optimization which is especially important for certain mount types, for
instance HTTP, for which opening a file to determine its status is
substantially less expensive than opening it to read its contents.
*/
- get_global_ptr()
C++ Interface: get_global_ptr()
- /**
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.
*/
- get_mount()
C++ Interface: get_mount(VirtualFileSystem self, int n)
- /**
Returns the nth mount in the system.
*/
- get_mounts()
- get_num_mounts()
C++ Interface: get_num_mounts(VirtualFileSystem self)
- /**
Returns the number of individual mounts in the system.
*/
- isDirectory()
C++ Interface: is_directory(VirtualFileSystem self, const Filename filename)
- /**
Convenience function; returns true if the named file exists as a directory in
the virtual file system hierarchy.
*/
- isRegularFile()
C++ Interface: is_regular_file(VirtualFileSystem self, const Filename filename)
- /**
Convenience function; returns true if the named file exists as a regular file
in the virtual file system hierarchy.
*/
- is_directory()
C++ Interface: is_directory(VirtualFileSystem self, const Filename filename)
- /**
Convenience function; returns true if the named file exists as a directory in
the virtual file system hierarchy.
*/
- is_regular_file()
C++ Interface: is_regular_file(VirtualFileSystem self, const Filename filename)
- /**
Convenience function; returns true if the named file exists as a regular file
in the virtual file system hierarchy.
*/
- ls()
C++ Interface: ls(VirtualFileSystem self, const Filename filename)
- /**
Convenience function; lists the files within the indicated directory.
*/
- lsAll()
C++ Interface: ls_all(VirtualFileSystem self, const Filename filename)
- /**
Convenience function; lists the files within the indicated directory, and
all files below, recursively.
*/
- ls_all()
C++ Interface: ls_all(VirtualFileSystem self, const Filename filename)
- /**
Convenience function; lists the files within the indicated directory, and
all files below, recursively.
*/
- makeDirectory()
C++ Interface: make_directory(const VirtualFileSystem self, const Filename filename)
- /**
Attempts to create a directory within the file system. Returns true on
success, false on failure (for instance, because the parent directory does
not exist, or is read-only). If the directory already existed prior to
this call, returns true.
*/
- makeDirectoryFull()
C++ Interface: make_directory_full(const VirtualFileSystem self, const Filename filename)
- /**
Attempts to create a directory within the file system. Will also create
any intervening directories needed. Returns true on success, false on
failure.
*/
- make_directory()
C++ Interface: make_directory(const VirtualFileSystem self, const Filename filename)
- /**
Attempts to create a directory within the file system. Returns true on
success, false on failure (for instance, because the parent directory does
not exist, or is read-only). If the directory already existed prior to
this call, returns true.
*/
- make_directory_full()
C++ Interface: make_directory_full(const VirtualFileSystem self, const Filename filename)
- /**
Attempts to create a directory within the file system. Will also create
any intervening directories needed. Returns true on success, false on
failure.
*/
- mount()
C++ Interface: mount(const VirtualFileSystem self, const Filename physical_filename, const Filename mount_point, int flags, str password) mount(const VirtualFileSystem self, VirtualFileMount mount, const Filename mount_point, int flags) mount(const VirtualFileSystem self, Multifile multifile, const Filename mount_point, int flags) mount(const VirtualFileSystem self, ZipArchive archive, const Filename mount_point, int flags)
- /**
Mounts the indicated Multifile at the given mount point.
*/
- /**
Mounts the indicated ZipArchive at the given mount point.
*/
- /**
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 (that is, two different files with exactly the same
full pathname), the most-recently mounted system wins.
The filename specified as the first parameter must refer to a real,
physical filename on disk; it cannot be a virtual file already appearing
within the vfs filespace. However, it is possible to mount such a file;
see mount_loop() for this.
Note that a mounted VirtualFileSystem directory is fully case-sensitive,
unlike the native Windows file system, so you must refer to files within
the virtual file system with exactly the right case.
*/
- /**
Adds the given VirtualFileMount object to the mount list. This is a lower-
level function than the other flavors of mount(); it requires you to create
a VirtualFileMount object specifically.
*/
- mountLoop()
C++ Interface: mount_loop(const VirtualFileSystem self, const Filename virtual_filename, const Filename mount_point, int flags, str password)
- /**
This is similar to mount(), but it receives the name of a Multifile that
already appears within the virtual file system. It can be used to mount a
Multifile that is itself hosted within a virtually-mounted Multifile.
This interface can also be used to mount physical files (that appear within
the virtual filespace), but it cannot be used to mount directories. Use
mount() if you need to mount a directory.
Note that there is additional overhead, in the form of additional buffer
copies of the data, for recursively mounting a multifile like this.
*/
- mount_loop()
C++ Interface: mount_loop(const VirtualFileSystem self, const Filename virtual_filename, const Filename mount_point, int flags, str password)
- /**
This is similar to mount(), but it receives the name of a Multifile that
already appears within the virtual file system. It can be used to mount a
Multifile that is itself hosted within a virtually-mounted Multifile.
This interface can also be used to mount physical files (that appear within
the virtual filespace), but it cannot be used to mount directories. Use
mount() if you need to mount a directory.
Note that there is additional overhead, in the form of additional buffer
copies of the data, for recursively mounting a multifile like this.
*/
- mounts
- openAppendFile()
C++ Interface: open_append_file(const VirtualFileSystem self, const Filename filename)
- /**
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().
*/
- openReadAppendFile()
C++ Interface: open_read_append_file(const VirtualFileSystem self, const Filename filename)
- /**
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().
*/
- openReadFile()
C++ Interface: open_read_file(VirtualFileSystem self, const Filename filename, bool auto_unwrap)
- /**
Convenience function; returns a newly allocated istream if the file exists
and can be read, or NULL otherwise. Does not return an invalid istream.
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.
*/
- openReadWriteFile()
C++ Interface: open_read_write_file(const VirtualFileSystem self, const Filename filename, bool truncate)
- /**
Convenience function; returns a newly allocated iostream if the file exists
and can be written, or NULL otherwise. Does not return an invalid
iostream.
*/
- openWriteFile()
C++ Interface: open_write_file(const VirtualFileSystem self, const Filename filename, bool auto_wrap, bool truncate)
- /**
Convenience function; returns a newly allocated ostream if the file exists
and can be written, or NULL otherwise. Does not return an invalid ostream.
If auto_wrap is true, an explicitly-named .pz file is automatically
compressed while writing. If truncate is true, the file is truncated to
zero length before writing.
*/
- open_append_file()
C++ Interface: open_append_file(const VirtualFileSystem self, const Filename filename)
- /**
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().
*/
- open_read_append_file()
C++ Interface: open_read_append_file(const VirtualFileSystem self, const Filename filename)
- /**
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().
*/
- open_read_file()
C++ Interface: open_read_file(VirtualFileSystem self, const Filename filename, bool auto_unwrap)
- /**
Convenience function; returns a newly allocated istream if the file exists
and can be read, or NULL otherwise. Does not return an invalid istream.
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.
*/
- open_read_write_file()
C++ Interface: open_read_write_file(const VirtualFileSystem self, const Filename filename, bool truncate)
- /**
Convenience function; returns a newly allocated iostream if the file exists
and can be written, or NULL otherwise. Does not return an invalid
iostream.
*/
- open_write_file()
C++ Interface: open_write_file(const VirtualFileSystem self, const Filename filename, bool auto_wrap, bool truncate)
- /**
Convenience function; returns a newly allocated ostream if the file exists
and can be written, or NULL otherwise. Does not return an invalid ostream.
If auto_wrap is true, an explicitly-named .pz file is automatically
compressed while writing. If truncate is true, the file is truncated to
zero length before writing.
*/
- readFile()
C++ Interface: read_file(VirtualFileSystem self, const Filename filename, bool auto_unwrap)
- /**
Convenience function; returns the entire contents of the indicated file as
a string.
If auto_unwrap is true, an explicitly-named .pz/.gz 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.
*/
- /**
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.
If auto_unwrap is true, an explicitly-named .pz/.gz 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.
*/
- /**
Convenience function; fills the pvector up with the data from the indicated
file, if it exists and can be read. Returns true on success, false
otherwise.
If auto_unwrap is true, an explicitly-named .pz/.gz 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.
*/
- read_file()
C++ Interface: read_file(VirtualFileSystem self, const Filename filename, bool auto_unwrap)
- /**
Convenience function; returns the entire contents of the indicated file as
a string.
If auto_unwrap is true, an explicitly-named .pz/.gz 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.
*/
- /**
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.
If auto_unwrap is true, an explicitly-named .pz/.gz 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.
*/
- /**
Convenience function; fills the pvector up with the data from the indicated
file, if it exists and can be read. Returns true on success, false
otherwise.
If auto_unwrap is true, an explicitly-named .pz/.gz 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.
*/
- renameFile()
C++ Interface: rename_file(const VirtualFileSystem self, const Filename orig_filename, const Filename new_filename)
- /**
Attempts to move or rename the indicated file or directory. If the
original file is an ordinary file, it will quietly replace any already-
existing file in the new filename (but not a directory). If the original
file is a directory, the new filename must not already exist.
If the file is a directory, the new filename must be within the same mount
point. If the file is an ordinary file, the new filename may be anywhere;
but if it is not within the same mount point then the rename operation is
automatically performed as a two-step copy-and-delete operation.
*/
- rename_file()
C++ Interface: rename_file(const VirtualFileSystem self, const Filename orig_filename, const Filename new_filename)
- /**
Attempts to move or rename the indicated file or directory. If the
original file is an ordinary file, it will quietly replace any already-
existing file in the new filename (but not a directory). If the original
file is a directory, the new filename must not already exist.
If the file is a directory, the new filename must be within the same mount
point. If the file is an ordinary file, the new filename may be anywhere;
but if it is not within the same mount point then the rename operation is
automatically performed as a two-step copy-and-delete operation.
*/
- resolveFilename()
C++ Interface: resolve_filename(VirtualFileSystem self, Filename filename, const DSearchPath searchpath, str default_extension)
- /**
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.
*/
- resolve_filename()
C++ Interface: resolve_filename(VirtualFileSystem self, Filename filename, const DSearchPath searchpath, str default_extension)
- /**
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.
*/
- scanDirectory()
C++ Interface: scan_directory(VirtualFileSystem self, const Filename filename)
- /**
If the file represents a directory (that is, is_directory() returns true),
this returns the list of files within the directory at the current time.
Returns NULL if the file is not a directory or if the directory cannot be
read.
*/
- scan_directory()
C++ Interface: scan_directory(VirtualFileSystem self, const Filename filename)
- /**
If the file represents a directory (that is, is_directory() returns true),
this returns the list of files within the directory at the current time.
Returns NULL if the file is not a directory or if the directory cannot be
read.
*/
- unmount()
C++ Interface: unmount(const VirtualFileSystem self, VirtualFileMount mount) unmount(const VirtualFileSystem self, Multifile multifile) unmount(const VirtualFileSystem self, ZipArchive archive)
- /**
Unmounts all appearances of the indicated Multifile from the file system.
Returns the number of appearances unmounted.
*/
- /**
Unmounts all appearances of the indicated ZipArchive from the file system.
Returns the number of appearances unmounted.
*/
- /**
Unmounts all appearances of the indicated directory name or multifile name
from the file system. Returns the number of appearances unmounted.
*/
- /**
Unmounts the indicated VirtualFileMount object from the file system.
Returns the number of appearances unmounted.
*/
- unmountAll()
C++ Interface: unmount_all(const VirtualFileSystem self)
- /**
Unmounts all files from the file system. Returns the number of systems
unmounted.
*/
- unmountPoint()
C++ Interface: unmount_point(const VirtualFileSystem self, const Filename mount_point)
- /**
Unmounts all systems attached to the given mount point from the file
system. Returns the number of appearances unmounted.
*/
- unmount_all()
C++ Interface: unmount_all(const VirtualFileSystem self)
- /**
Unmounts all files from the file system. Returns the number of systems
unmounted.
*/
- unmount_point()
C++ Interface: unmount_point(const VirtualFileSystem self, const Filename mount_point)
- /**
Unmounts all systems attached to the given mount point from the file
system. Returns the number of appearances unmounted.
*/
- write()
C++ Interface: write(VirtualFileSystem self, ostream out)
- /**
Print debugging information. (e.g. from Python or gdb prompt).
*/
- writeFile()
C++ Interface: write_file(const VirtualFileSystem self, const Filename filename, object data, bool auto_wrap)
- /**
Convenience function; writes the entire contents of the indicated file as a
string.
If auto_wrap is true, an explicitly-named .pz file is automatically
compressed while writing.
*/
- /**
Convenience function; writes the entire contents of the indicated file as a
block of data.
If auto_wrap is true, an explicitly-named .pz file is automatically
compressed while writing.
*/
- write_file()
C++ Interface: write_file(const VirtualFileSystem self, const Filename filename, object data, bool auto_wrap)
- /**
Convenience function; writes the entire contents of the indicated file as a
string.
If auto_wrap is true, an explicitly-named .pz file is automatically
compressed while writing.
*/
- /**
Convenience function; writes the entire contents of the indicated file as a
block of data.
If auto_wrap is true, an explicitly-named .pz file is automatically
compressed while writing.
*/