21 using std::streamsize;
24 TypeHandle VirtualFileMountSystem::_type_handle;
32 Filename pathname(_physical_filename, file);
39 if (case_pathname != pathname) {
41 <<
"Filename is incorrect case: " << pathname
42 <<
" instead of " << case_pathname <<
"\n";
57 Filename pathname(_physical_filename, file);
70 Filename pathname(_physical_filename, file);
82 Filename orig_pathname(_physical_filename, orig_filename);
83 Filename new_pathname(_physical_filename, new_filename);
84 return orig_pathname.
rename_to(new_pathname);
95 Filename orig_pathname(_physical_filename, orig_filename);
96 Filename new_pathname(_physical_filename, new_filename);
97 return orig_pathname.
copy_to(new_pathname);
108 Filename pathname(_physical_filename, file);
109 return pathname.
mkdir();
126 Filename pathname(_physical_filename, file);
144 Filename pathname(_physical_filename, file);
162 Filename pathname(_physical_filename, file);
181 Filename pathname(_physical_filename, file);
182 pifstream *stream =
new pifstream;
207 Filename pathname(_physical_filename, file);
208 pofstream *stream =
new pofstream;
209 if (!pathname.
open_write(*stream, truncate)) {
233 Filename pathname(_physical_filename, file);
234 pofstream *stream =
new pofstream;
259 Filename pathname(_physical_filename, file);
260 pfstream *stream =
new pfstream;
285 Filename pathname(_physical_filename, file);
286 pfstream *stream =
new pfstream;
304 streampos orig = stream->tellg();
307 stream->seekg(0, std::ios::end);
308 if (stream->fail()) {
313 streampos size = stream->tellg();
316 stream->seekg(orig, std::ios::beg);
330 Filename pathname(_physical_filename, file);
346 Filename pathname(_physical_filename, file);
359 Filename pathname(_physical_filename, file);
379 Filename pathname(_physical_filename, dir);
389 const string &old_contents,
390 const string &new_contents) {
399 Filename pathname(_physical_filename, file);
416 Filename pathname(_physical_filename, file);
423 void VirtualFileMountSystem::
424 output(ostream &out)
const {
virtual bool make_directory(const Filename &file)
Attempts to create the indicated file within the mount, if it does not already exist.
virtual void close_write_file(std::ostream *stream)
Closes a file opened by a previous call to open_write_file().
bool open_write(std::ofstream &stream, bool truncate=true) const
Opens the indicated ifstream for writing the file, if possible.
virtual bool is_directory(const Filename &file) const
Returns true if the indicated file exists within the mount system and is a directory.
virtual void close_read_file(std::istream *stream) const
Closes a file opened by a previous call to open_read_file().
bool open_append(std::ofstream &stream) const
Opens the indicated ofstream for writing the file, if possible.
time_t get_timestamp() const
Returns a time_t value that represents the time the file was last modified, to within whatever precis...
virtual bool has_file(const Filename &file) const
Returns true if the indicated file exists within the mount system.
virtual std::istream * open_read_file(const Filename &file) const
Opens the file for reading, if it exists.
virtual std::iostream * open_read_write_file(const Filename &file, bool truncate)
Opens the file for writing.
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.
void set_binary()
Indicates that the filename represents a binary file.
bool open_read(std::ifstream &stream) const
Opens the indicated ifstream for reading the file, if possible.
virtual void close_read_write_file(std::iostream *stream)
Closes a file opened by a previous call to open_read_write_file().
bool make_true_case()
On a case-insensitive operating system (e.g.
bool copy_to(const Filename &other) const
Copies the file to the indicated new filename, by reading the contents and writing it to the new file...
virtual std::ostream * open_write_file(const Filename &file, bool truncate)
Opens the file for writing.
bool atomic_compare_and_exchange_contents(std::string &orig_contents, const std::string &old_contents, const std::string &new_contents) const
Uses native file-locking mechanisms to atomically replace the contents of a (small) file with the spe...
virtual std::ostream * open_append_file(const Filename &file)
Works like open_write_file(), but the file is opened in append mode.
virtual std::streamsize get_file_size(const Filename &file, std::istream *stream) const
Returns the current size on disk (or wherever it is) of the already-open 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 rename_file(const Filename &orig_filename, const Filename &new_filename)
Attempts to rename the contents of the indicated file to the indicated file.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual bool atomic_compare_and_exchange_contents(const Filename &file, std::string &orig_contents, const std::string &old_contents, const std::string &new_contents)
See Filename::atomic_compare_and_exchange_contents().
The name of a file, such as a texture file or an Egg file.
bool atomic_read_contents(std::string &contents) const
Uses native file-locking mechanisms to atomically read the contents of a (small) file.
static VirtualFileSystem * get_global_ptr()
Returns the default global VirtualFileSystem.
const Filename & get_physical_filename() const
Returns the name of the source file on the OS filesystem of the directory or file that is mounted.
bool unlink() const
Permanently deletes the file associated with the filename, if possible.
bool is_regular_file() const
Returns true if the filename exists and is the name of a regular file (i.e.
bool open_read_append(std::fstream &stream) const
Opens the indicated ifstream for reading and writing the file, if possible; writes are appended to th...
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 precis...
bool is_directory() const
Returns true if the filename exists and is a directory name, false otherwise.
bool is_writable() const
Returns true if the filename exists and is either a directory or a regular file that can be written t...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class records a particular byte sub-range within an existing file on disk.
std::streamsize get_file_size() const
Returns the size of the file in bytes, or 0 if there is an error.
bool rmdir() const
The inverse of mkdir(): this removes the directory named by this Filename, if it is in fact a directo...
virtual bool delete_file(const Filename &file)
Attempts to delete the indicated file or directory within the mount.
bool scan_directory(vector_string &contents) const
Attempts to open the named filename as if it were a directory and looks for the non-hidden files with...
bool open_read_write(std::fstream &stream, bool truncate=false) const
Opens the indicated fstream for read/write access to the file, if possible.
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,...
TypeHandle is the identifier used to differentiate C++ class types.
virtual std::iostream * open_read_append_file(const Filename &file)
Works like open_read_write_file(), but the file is opened in append mode.
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.
bool rename_to(const Filename &other) const
Renames the file to the indicated new filename.
virtual bool atomic_read_contents(const Filename &file, std::string &contents) const
See Filename::atomic_read_contents().
bool exists() const
Returns true if the filename exists on the disk, false otherwise.
virtual bool is_writable(const Filename &file) const
Returns true if the named file or directory may be written to, false otherwise.
bool mkdir() const
Creates the directory named by this filename.
virtual bool get_system_info(const Filename &file, SubfileInfo &info)
Populates the SubfileInfo structure with the data representing where the file actually resides on dis...