32 return _mount->get_file_system();
40 string mount_point = _mount->get_mount_point();
41 if (_local_filename.empty()) {
42 if (mount_point.empty()) {
45 return string(
"/") + mount_point;
49 if (mount_point.empty()) {
50 return string(
"/") + _local_filename.get_fullpath();
52 return string(
"/") + mount_point + string(
"/") + _local_filename.get_fullpath();
62 return _mount->has_file(_local_filename);
80 return _mount->is_regular_file(_local_filename);
89 return _mount->is_writable(_local_filename);
99 return _mount->delete_file(_local_filename);
115 if (new_file->
is_of_type(VirtualFileSimple::get_class_type())) {
116 VirtualFileSimple *new_file_simple = DCAST(VirtualFileSimple, new_file);
117 if (new_file_simple->_mount == _mount) {
119 if (_mount->rename_file(_local_filename, new_file_simple->_local_filename)) {
145 if (new_file->
is_of_type(VirtualFileSimple::get_class_type())) {
146 VirtualFileSimple *new_file_simple = DCAST(VirtualFileSimple, new_file);
147 if (new_file_simple->_mount == _mount) {
149 if (_mount->copy_file(_local_filename, new_file_simple->_local_filename)) {
158 if (out ==
nullptr) {
169 static const size_t buffer_size = 4096;
170 char buffer[buffer_size];
172 in->read(buffer, buffer_size);
173 size_t count = in->gcount();
175 out->write(buffer, count);
182 in->read(buffer, buffer_size);
183 count = in->gcount();
212 bool do_uncompress = (_implicit_pz_file ||
213 (auto_unwrap && (_local_filename.get_extension() ==
"pz" ||
214 _local_filename.get_extension() ==
"gz")));
216 Filename local_filename(_local_filename);
222 return _mount->open_read_file(local_filename, do_uncompress);
233 _mount->close_read_file(stream);
248 bool do_compress = (_implicit_pz_file || (auto_wrap && _local_filename.get_extension() ==
"pz"));
250 Filename local_filename(_local_filename);
256 return _mount->open_write_file(local_filename, do_compress, truncate);
266 return _mount->open_append_file(_local_filename);
277 _mount->close_write_file(stream);
287 return _mount->open_read_write_file(_local_filename, truncate);
297 return _mount->open_read_append_file(_local_filename);
308 _mount->close_read_write_file(stream);
318 return _mount->get_file_size(_local_filename, stream);
327 return _mount->get_file_size(_local_filename);
342 return _mount->get_timestamp(_local_filename);
354 return _mount->get_system_info(_local_filename, info);
362 const string &old_contents,
363 const string &new_contents) {
364 return _mount->atomic_compare_and_exchange_contents(_local_filename, orig_contents, old_contents, new_contents);
372 return _mount->atomic_read_contents(_local_filename, contents);
380read_file(vector_uchar &result,
bool auto_unwrap)
const {
383 bool do_uncompress = (_implicit_pz_file ||
384 (auto_unwrap && (_local_filename.get_extension() ==
"pz" ||
385 _local_filename.get_extension() ==
"gz")));
387 Filename local_filename(_local_filename);
393 return _mount->read_file(local_filename, do_uncompress, result);
401write_file(
const unsigned char *data,
size_t data_size,
bool auto_wrap) {
403 bool do_compress = (_implicit_pz_file || (auto_wrap && _local_filename.get_extension() ==
"pz"));
405 Filename local_filename(_local_filename);
411 return _mount->write_file(local_filename, do_compress, data, data_size);
420bool VirtualFileSimple::
424 if (!_mount->scan_directory(names, _local_filename)) {
435 vector_string::const_iterator ni;
436 for (ni = names.begin(); ni != names.end(); ++ni) {
437 const string &basename = (*ni);
438 if (mount_points.find(basename) == mount_points.
end()) {
439 Filename filename(_local_filename, basename);
440 VirtualFileSimple *file =
new VirtualFileSimple(_mount, filename,
false, 0);
The name of a file, such as a texture file or an Egg file.
void set_binary()
Indicates that the filename represents a binary file.
bool is_directory() const
Returns true if the filename exists on the physical disk and is a directory name, false otherwise.
This class records a particular byte sub-range within an existing file on disk.
TypeHandle is the identifier used to differentiate C++ class types.
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
A list of VirtualFiles, as returned by VirtualFile::scan_directory().
void add_file(VirtualFile *file)
Adds a new file to the list.
virtual bool read_file(vector_uchar &result, bool auto_unwrap) const
Fills up the indicated pvector with the contents of the file, if it is a regular file.
virtual std::ostream * open_append_file()
Works like open_write_file(), but the file is opened in append mode.
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().
virtual bool atomic_read_contents(std::string &contents) const
See Filename::atomic_read_contents().
virtual bool get_system_info(SubfileInfo &info)
Populates the SubfileInfo structure with the data representing where the file actually resides on dis...
virtual bool is_regular_file() const
Returns true if this file represents a regular file (and read_file() may be called),...
virtual bool has_file() const
Returns true if this file exists, false otherwise.
virtual std::ostream * open_write_file(bool auto_wrap, bool truncate)
Opens the file for writing.
virtual VirtualFileSystem * get_file_system() const
Returns the VirtualFileSystem this file is associated with.
virtual bool delete_file()
Attempts to delete this file or directory.
virtual bool write_file(const unsigned char *data, size_t data_size, bool auto_wrap)
Writes the indicated data to the file, if it is writable.
virtual bool copy_file(VirtualFile *new_file)
Attempts to copy the contents of this file to the indicated file.
virtual std::iostream * open_read_write_file(bool truncate)
Opens the file for writing.
virtual std::istream * open_read_file(bool auto_unwrap) const
Opens the file for reading.
virtual time_t get_timestamp() const
Returns a time_t value that represents the time the file was last modified, to within whatever precis...
virtual std::iostream * open_read_append_file()
Works like open_read_write_file(), but the file is opened in append mode.
virtual void close_write_file(std::ostream *stream)
Closes a file opened by a previous call to open_write_file().
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 bool is_directory() const
Returns true if this file represents a directory (and scan_directory() may be called),...
virtual bool is_writable() const
Returns true if this file represents a writable regular file (and write_file() 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 Filename get_filename() const
Returns the full pathname to this file within the virtual file system.
virtual std::streamsize get_file_size() const
Returns the current size on disk (or wherever it is) of the file before it has been opened.
A hierarchy of directories and files that appears to be one continuous file system,...
virtual bool delete_file()
Attempts to delete this file or directory.
virtual std::ostream * open_write_file(bool auto_wrap, bool truncate)
Opens the file for writing.
virtual bool is_directory() const
Returns true if this file represents a directory (and scan_directory() may be called),...
virtual void close_write_file(std::ostream *stream)
Closes a file opened by a previous call to open_write_file().
iterator_0 end()
Returns the iterator that marks the end of the ordered vector.
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.