Panda3D
virtualFileMountSystem.h
1 // Filename: virtualFileMountSystem.h
2 // Created by: drose (03Aug02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef VIRTUALFILEMOUNTSYSTEM_H
16 #define VIRTUALFILEMOUNTSYSTEM_H
17 
18 #include "pandabase.h"
19 
20 #include "virtualFileMount.h"
21 
22 ////////////////////////////////////////////////////////////////////
23 // Class : VirtualFileMountSystem
24 // Description : Maps an actual OS directory into the
25 // VirtualFileSystem.
26 ////////////////////////////////////////////////////////////////////
27 class EXPCL_PANDAEXPRESS VirtualFileMountSystem : public VirtualFileMount {
28 PUBLISHED:
29  INLINE VirtualFileMountSystem(const Filename &physical_filename);
30 
31  INLINE const Filename &get_physical_filename() const;
32 
33 public:
34  virtual bool has_file(const Filename &file) const;
35  virtual bool create_file(const Filename &file);
36  virtual bool make_directory(const Filename &file);
37  virtual bool delete_file(const Filename &file);
38  virtual bool rename_file(const Filename &orig_filename, const Filename &new_filename);
39  virtual bool copy_file(const Filename &orig_filename, const Filename &new_filename);
40  virtual bool is_directory(const Filename &file) const;
41  virtual bool is_regular_file(const Filename &file) const;
42  virtual bool is_writable(const Filename &file) const;
43 
44  virtual istream *open_read_file(const Filename &file) const;
45  virtual ostream *open_write_file(const Filename &file, bool truncate);
46  virtual ostream *open_append_file(const Filename &file);
47  virtual iostream *open_read_write_file(const Filename &file, bool truncate);
48  virtual iostream *open_read_append_file(const Filename &file);
49 
50  virtual streamsize get_file_size(const Filename &file, istream *stream) const;
51  virtual streamsize get_file_size(const Filename &file) const;
52  virtual time_t get_timestamp(const Filename &file) const;
53  virtual bool get_system_info(const Filename &file, SubfileInfo &info);
54 
55  virtual bool scan_directory(vector_string &contents,
56  const Filename &dir) const;
57 
58  virtual bool atomic_compare_and_exchange_contents(const Filename &file, string &orig_contents, const string &old_contents, const string &new_contents);
59  virtual bool atomic_read_contents(const Filename &file, string &contents) const;
60 
61  virtual void output(ostream &out) const;
62 
63 private:
64  Filename _physical_filename;
65 
66 public:
67  virtual TypeHandle get_type() const {
68  return get_class_type();
69  }
70  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
71  static TypeHandle get_class_type() {
72  return _type_handle;
73  }
74  static void init_type() {
75  VirtualFileMount::init_type();
76  register_type(_type_handle, "VirtualFileMountSystem",
77  VirtualFileMount::get_class_type());
78  }
79 
80 private:
81  static TypeHandle _type_handle;
82 };
83 
84 #include "virtualFileMountSystem.I"
85 
86 #endif
Maps an actual OS directory into the VirtualFileSystem.
virtual bool delete_file(const Filename &file)
Attempts to delete the indicated file or directory within the mount.
virtual bool atomic_read_contents(const Filename &file, string &contents) const
See Filename::atomic_read_contents().
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.
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.
Definition: filename.h:44
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.
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...
The abstract base class for a mount definition used within a VirtualFileSystem.
This class records a particular byte sub-range within an existing file on disk.
Definition: subfileInfo.h:29
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
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.