14#ifndef VIRTUALFILESYSTEM_H
15#define VIRTUALFILESYSTEM_H
40class EXPCL_PANDA_EXPRESS VirtualFileSystem {
46 MF_read_only = 0x0002,
51 int flags,
const std::string &password =
"");
53 int flags,
const std::string &password =
"");
75 bool status_only =
false)
const;
81 const std::string &default_extension = std::string())
const;
91 INLINE
void ls(
const Filename &filename)
const;
92 INLINE
void ls_all(
const Filename &filename)
const;
94 void write(std::ostream &out)
const;
98 EXTENSION(PyObject *read_file(
const Filename &filename,
bool auto_unwrap)
const);
102 EXTENSION(PyObject *write_file(
const Filename &filename, PyObject *data,
bool auto_wrap));
114 BLOCKING INLINE std::string read_file(
const Filename &filename,
bool auto_unwrap)
const;
115 BLOCKING INLINE
bool write_file(
const Filename &filename,
const std::string &data,
bool auto_wrap);
120 INLINE
bool read_file(
const Filename &filename, std::string &result,
bool auto_unwrap)
const;
121 INLINE
bool read_file(
const Filename &filename, vector_uchar &result,
bool auto_unwrap)
const;
122 INLINE
bool write_file(
const Filename &filename,
const unsigned char *data,
size_t data_size,
bool auto_wrap);
127 int &flags, std::string &password);
129 int &flags, std::string &password);
136 OF_status_only = 0x0001,
137 OF_create_file = 0x0002,
138 OF_make_directory = 0x0004,
139 OF_allow_nonexist = 0x0008,
156 const Filename &original_filename,
bool implicit_pz_file,
157 int open_flags)
const;
158 bool consider_mount_mf(
const Filename &filename);
160 mutable MutexImpl _lock;
163 unsigned int _mount_seq;
This is a convenience class to specialize ConfigVariable as a boolean type.
This class stores a list of directories that can be searched, in order, to locate a particular file.
The name of a file, such as a texture file or an Egg file.
A file that contains a set of files.
A composite directory within the VirtualFileSystem: this maps to more than one directory on different...
A list of VirtualFiles, as returned by VirtualFile::scan_directory().
The abstract base class for a mount definition used within a VirtualFileSystem.
A hierarchy of directories and files that appears to be one continuous file system,...
bool rename_file(const Filename &orig_filename, const Filename &new_filename)
Attempts to move or rename the indicated file or directory.
static void close_write_file(std::ostream *stream)
Closes a file opened by a previous call to open_write_file().
std::iostream * open_read_write_file(const Filename &filename, bool truncate)
Convenience function; returns a newly allocated iostream if the file exists and can be written,...
int unmount_point(const Filename &mount_point)
Unmounts all systems attached to the given mount point from the file system.
Filename get_cwd() const
Returns the current directory name.
void write(std::ostream &out) const
Print debugging information.
bool exists(const Filename &filename) const
Convenience function; returns true if the named file exists in the virtual file system hierarchy.
int unmount(Multifile *multifile)
Unmounts all appearances of the indicated Multifile from the file system.
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 is_regular_file(const Filename &filename) const
Convenience function; returns true if the named file exists as a regular file in the virtual file sys...
PointerTo< VirtualFile > find_file(const Filename &filename, const DSearchPath &searchpath, bool status_only=false) const
Uses the indicated search path to find the file within the file system.
bool resolve_filename(Filename &filename, const DSearchPath &searchpath, const std::string &default_extension=std::string()) const
Searches the given search path for the filename.
std::ostream * open_append_file(const Filename &filename)
Works like open_write_file(), but the file is opened in append mode.
std::ostream * open_write_file(const Filename &filename, bool auto_wrap, bool truncate)
Convenience function; returns a newly allocated ostream if the file exists and can be written,...
static void close_read_file(std::istream *stream)
Closes a file opened by a previous call to open_read_file().
static void close_read_write_file(std::iostream *stream)
Closes a file opened by a previous call to open_read_write_file().
static void parse_options(const std::string &options, int &flags, std::string &password)
Parses all of the option flags in the options list on the vfs-mount Config.prc line.
PointerTo< VirtualFile > create_file(const Filename &filename)
Attempts to create a file by the indicated name in the filesystem, if possible, and returns it.
static void parse_option(const std::string &option, int &flags, std::string &password)
Parses one of the option flags in the options list on the vfs-mount Config.prc line.
std::iostream * open_read_append_file(const Filename &filename)
Works like open_read_write_file(), but the file is opened in append mode.
bool mount_loop(const Filename &virtual_filename, const Filename &mount_point, int flags, const std::string &password="")
This is similar to mount(), but it receives the name of a Multifile that already appears within the v...
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,...
get_mount
Returns the nth mount in the system.
bool is_directory(const Filename &filename) const
Convenience function; returns true if the named file exists as a directory in the virtual file system...
bool chdir(const Filename &new_directory)
Changes the current directory.
get_num_mounts
Returns the number of individual mounts in the system.
bool atomic_compare_and_exchange_contents(const Filename &filename, std::string &orig_contents, const std::string &old_contents, const std::string &new_contents)
See Filename::atomic_compare_and_exchange_contents().
PointerTo< VirtualFile > get_file(const Filename &filename, bool status_only=false) const
Looks up the file by the indicated name in the file system.
std::istream * open_read_file(const Filename &filename, bool auto_unwrap) const
Convenience function; returns a newly allocated istream if the file exists and can be read,...
bool delete_file(const Filename &filename)
Attempts to delete the indicated file or directory.
bool make_directory_full(const Filename &filename)
Attempts to create a directory within the file system.
bool make_directory(const Filename &filename)
Attempts to create a directory within the file system.
bool mount(Multifile *multifile, const Filename &mount_point, int flags)
Mounts the indicated Multifile at the given mount point.
bool copy_file(const Filename &orig_filename, const Filename &new_filename)
Attempts to copy the contents of the indicated file to the indicated file.
int unmount_all()
Unmounts all files from the file system.
static VirtualFileSystem * get_global_ptr()
Returns the default global VirtualFileSystem.
bool atomic_read_contents(const Filename &filename, std::string &contents) const
See Filename::atomic_read_contents().
The abstract base class for a file or directory within the VirtualFileSystem.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.