14 #ifndef VIRTUALFILEMOUNTRAMDISK_H 15 #define VIRTUALFILEMOUNTRAMDISK_H 35 virtual bool has_file(
const Filename &file)
const;
41 virtual bool is_directory(
const Filename &file)
const;
42 virtual bool is_regular_file(
const Filename &file)
const;
45 virtual std::istream *open_read_file(
const Filename &file)
const;
51 virtual std::streamsize get_file_size(
const Filename &file, std::istream *stream)
const;
52 virtual std::streamsize get_file_size(
const Filename &file)
const;
53 virtual time_t get_timestamp(
const Filename &file)
const;
55 virtual bool scan_directory(vector_string &contents,
61 virtual void output(std::ostream &out)
const;
70 INLINE FileBase(
const std::string &basename);
72 INLINE
bool operator < (
const FileBase &other)
const;
74 virtual bool is_directory()
const;
76 std::string _basename;
81 return get_class_type();
83 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
87 static void init_type() {
88 TypedReferenceCount::init_type();
89 register_type(_type_handle,
"VirtualFileMountRamdisk::FileBase",
90 TypedReferenceCount::get_class_type());
97 class File :
public FileBase {
99 INLINE File(
const std::string &basename);
101 std::stringstream _data;
106 return get_class_type();
108 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
112 static void init_type() {
113 FileBase::init_type();
115 FileBase::get_class_type());
124 class Directory :
public FileBase {
126 INLINE Directory(
const std::string &basename);
128 virtual bool is_directory()
const;
130 PT(FileBase) do_find_file(
const std::string &filename)
const;
131 PT(File) do_create_file(
const std::string &filename);
132 PT(Directory) do_make_directory(
const std::string &filename);
133 PT(FileBase) do_delete_file(
const std::string &filename);
134 bool do_scan_directory(vector_string &contents)
const;
140 return get_class_type();
142 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
146 static void init_type() {
147 FileBase::init_type();
148 register_type(_type_handle,
"VirtualFileMountRamdisk::Directory",
149 FileBase::get_class_type());
161 return get_class_type();
163 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
167 static void init_type() {
168 VirtualFileMount::init_type();
170 VirtualFileMount::get_class_type());
171 FileBase::init_type();
173 Directory::init_type();
An STL function object class, this is intended to be used on any ordered collection of pointers to cl...
virtual bool atomic_read_contents(const Filename &file, std::string &contents) const
See Filename::atomic_read_contents().
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.
virtual bool delete_file(const Filename &file)
Attempts to delete the indicated file or directory within the mount.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
This class provides a locking wrapper around a combination ostream/istream pointer.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
Simulates an actual directory on disk with in-memory storage.
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.
virtual bool is_writable(const Filename &file) const
Returns true if the named file or directory may be written to, false otherwise.
virtual bool create_file(const Filename &file)
Attempts to create the indicated file within the mount, if it does not already exist.
The name of a file, such as a texture file or an Egg file.
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().
virtual std::ostream * open_append_file(const Filename &file)
Works like open_write_file(), but the file is opened in append mode.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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 make_directory(const Filename &file)
Attempts to create the indicated file within the mount, if it does not already exist.
The abstract base class for a mount definition used within a VirtualFileSystem.
A fake mutex implementation for single-threaded applications that don't need any synchronization cont...
This is our own Panda specialization on the default STL set.
TypeHandle is the identifier used to differentiate C++ class types.
virtual std::ostream * open_write_file(const Filename &file, bool truncate)
Opens the file for writing.
virtual std::iostream * open_read_write_file(const Filename &file, bool truncate)
Opens the file for writing.