35class EXPCL_PANDA_EXPRESS VirtualFile :
public TypedReferenceCount {
41 virtual Filename get_filename()
const=0;
50 BLOCKING
virtual bool rename_file(VirtualFile *new_file);
51 BLOCKING
virtual bool copy_file(VirtualFile *new_file);
55 void output(std::ostream &out)
const;
56 BLOCKING
void ls(std::ostream &out = std::cout)
const;
57 BLOCKING
void ls_all(std::ostream &out = std::cout)
const;
59 EXTENSION(PyObject *
read_file(
bool auto_unwrap)
const);
60 BLOCKING
virtual std::istream *
open_read_file(
bool auto_unwrap)
const;
64 EXTENSION(PyObject *
write_file(PyObject *data,
bool auto_wrap));
65 BLOCKING
virtual std::ostream *
open_write_file(
bool auto_wrap,
bool truncate);
73 BLOCKING
virtual std::streamsize
get_file_size(std::istream *stream)
const;
83 INLINE std::string
read_file(
bool auto_unwrap)
const;
84 INLINE
bool write_file(
const std::string &data,
bool auto_wrap);
87 bool read_file(std::string &result,
bool auto_unwrap)
const;
88 virtual bool read_file(vector_uchar &result,
bool auto_unwrap)
const;
89 virtual bool write_file(
const unsigned char *data,
size_t data_size,
bool auto_wrap);
92 static bool simple_read_file(std::istream *stream, vector_uchar &result,
size_t max_bytes);
99 void r_ls_all(std::ostream &out,
const Filename &root)
const;
106 return get_class_type();
108 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
112 static void init_type() {
113 TypedReferenceCount::init_type();
115 TypedReferenceCount::get_class_type());
121 friend class VirtualFileComposite;
124INLINE std::ostream &operator << (std::ostream &out,
const VirtualFile &file);
The name of a file, such as a texture file or an Egg file.
This class records a particular byte sub-range within an existing file on disk.
TypeHandle is the identifier used to differentiate C++ class types.
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,...
The abstract base class for a file or directory within the VirtualFileSystem.
virtual std::iostream * open_read_append_file()
Works like open_read_write_file(), but the file is opened in append mode.
virtual void close_read_file(std::istream *stream) const
Closes a file opened by a previous call to open_read_file().
virtual bool rename_file(VirtualFile *new_file)
Attempts to move or rename this file or directory.
virtual std::istream * open_read_file(bool auto_unwrap) const
Opens the file for reading.
virtual bool is_regular_file() const
Returns true if this file represents a regular file (and read_file() may be called),...
virtual bool copy_file(VirtualFile *new_file)
Attempts to copy the contents of this file to the indicated file.
virtual bool get_system_info(SubfileInfo &info)
Populates the SubfileInfo structure with the data representing where the file actually resides on dis...
PointerTo< VirtualFileList > scan_directory() const
If the file represents a directory (that is, is_directory() returns true), this returns the list of f...
virtual bool delete_file()
Attempts to delete this file or directory.
const Filename & get_original_filename() const
Returns the original filename as it was used to locate this VirtualFile.
virtual std::ostream * open_write_file(bool auto_wrap, bool truncate)
Opens the file for writing.
void ls_all(std::ostream &out=std::cout) const
If the file represents a directory, recursively lists its contents and those of all subdirectories.
virtual std::streamsize get_file_size(std::istream *stream) const
Returns the current size on disk (or wherever it is) of the already-open file.
static bool simple_read_file(std::istream *stream, vector_uchar &result)
Fills up the indicated pvector with the contents of the just-opened file.
virtual bool is_writable() const
Returns true if this file may be written to, which implies write_file() may be called (unless it is a...
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),...
virtual void close_read_write_file(std::iostream *stream)
Closes a file opened by a previous call to open_read_write_file().
virtual bool atomic_read_contents(std::string &contents) const
See Filename::atomic_read_contents().
virtual bool was_read_successful() const
Call this method after a reading the istream returned by open_read_file() to completion.
virtual bool atomic_compare_and_exchange_contents(std::string &orig_contents, const std::string &old_contents, const std::string &new_contents)
See Filename::atomic_compare_and_exchange_contents().
std::string read_file(bool auto_unwrap) const
Returns the entire contents of the file as a string.
void ls(std::ostream &out=std::cout) const
If the file represents a directory, lists its contents.
virtual std::ostream * open_append_file()
Works like open_write_file(), but the file is opened in append mode.
virtual time_t get_timestamp() const
Returns a time_t value that represents the time the file was last modified, to within whatever precis...
void set_original_filename(const Filename &filename)
Stores the original filename that was used to locate this VirtualFile.
virtual std::iostream * open_read_write_file(bool truncate)
Opens the file for writing.
virtual void close_write_file(std::ostream *stream)
Closes a file opened by a previous call to open_write_file().
bool write_file(const std::string &data, bool auto_wrap)
Writes the entire contents of the file as a string, if it is writable.
A specialization of ordered_vector that emulates a standard STL set: one copy of each element is allo...
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.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
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.