15 #ifndef VIRTUALFILEMOUNTRAMDISK_H
16 #define VIRTUALFILEMOUNTRAMDISK_H
18 #include "pandabase.h"
20 #include "virtualFileMount.h"
21 #include "mutexImpl.h"
22 #include "streamWrapper.h"
39 virtual bool has_file(
const Filename &file)
const;
45 virtual bool is_directory(
const Filename &file)
const;
46 virtual bool is_regular_file(
const Filename &file)
const;
49 virtual istream *open_read_file(
const Filename &file)
const;
55 virtual streamsize get_file_size(
const Filename &file, istream *stream)
const;
56 virtual streamsize get_file_size(
const Filename &file)
const;
57 virtual time_t get_timestamp(
const Filename &file)
const;
59 virtual bool scan_directory(vector_string &contents,
65 virtual void output(ostream &out)
const;
74 INLINE FileBase(
const string &basename);
76 INLINE
bool operator < (
const FileBase &other)
const;
78 virtual bool is_directory()
const;
85 return get_class_type();
87 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
91 static void init_type() {
92 TypedReferenceCount::init_type();
93 register_type(_type_handle,
"VirtualFileMountRamdisk::FileBase",
94 TypedReferenceCount::get_class_type());
101 class File :
public FileBase {
103 INLINE File(
const string &basename);
110 return get_class_type();
112 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
116 static void init_type() {
117 FileBase::init_type();
118 register_type(_type_handle,
"VirtualFileMountRamdisk::File",
119 FileBase::get_class_type());
128 class Directory :
public FileBase {
130 INLINE Directory(
const string &basename);
132 virtual bool is_directory()
const;
134 PT(FileBase) do_find_file(
const string &filename)
const;
135 PT(File) do_create_file(
const string &filename);
136 PT(Directory) do_make_directory(
const string &filename);
137 PT(FileBase) do_delete_file(
const string &filename);
138 bool do_scan_directory(vector_string &contents)
const;
144 return get_class_type();
146 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
150 static void init_type() {
151 FileBase::init_type();
152 register_type(_type_handle,
"VirtualFileMountRamdisk::Directory",
153 FileBase::get_class_type());
165 return get_class_type();
167 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
171 static void init_type() {
172 VirtualFileMount::init_type();
173 register_type(_type_handle,
"VirtualFileMountRamdisk",
174 VirtualFileMount::get_class_type());
175 FileBase::init_type();
177 Directory::init_type();
184 #include "virtualFileMountRamdisk.I"
virtual bool delete_file(const Filename &file)
Attempts to delete the indicated file or directory within the mount.
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.
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 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 is_writable(const Filename &file) const
Returns true if the named file or directory may be written to, false otherwise.
virtual ostream * open_append_file(const Filename &file)
Works like open_write_file(), but the file is opened in append mode.
virtual 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.
virtual bool atomic_read_contents(const Filename &file, string &contents) const
See Filename::atomic_read_contents().
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 bool atomic_compare_and_exchange_contents(const Filename &file, string &orig_contents, const string &old_contents, const string &new_contents)
See Filename::atomic_compare_and_exchange_contents().
virtual ostream * open_write_file(const Filename &file, bool truncate)
Opens the file for writing.
virtual iostream * open_read_write_file(const Filename &file, bool truncate)
Opens the file for writing.