Panda3D
virtualFileMount.h
1 // Filename: virtualFileMount.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 VIRTUALFILEMOUNT_H
16 #define VIRTUALFILEMOUNT_H
17 
18 #include "pandabase.h"
19 
20 #include "virtualFile.h"
21 #include "filename.h"
22 #include "pointerTo.h"
23 #include "typedReferenceCount.h"
24 
25 class VirtualFileSystem;
26 
27 ////////////////////////////////////////////////////////////////////
28 // Class : VirtualFileMount
29 // Description : The abstract base class for a mount definition used
30 // within a VirtualFileSystem. Normally users don't
31 // need to monkey with this class directly.
32 ////////////////////////////////////////////////////////////////////
33 class EXPCL_PANDAEXPRESS VirtualFileMount : public TypedReferenceCount {
34 PUBLISHED:
35  INLINE VirtualFileMount();
36  virtual ~VirtualFileMount();
37 
38  INLINE VirtualFileSystem *get_file_system() const;
39  INLINE const Filename &get_mount_point() const;
40  INLINE int get_mount_flags() const;
41 
42 public:
43  virtual PT(VirtualFile) make_virtual_file(const Filename &local_filename,
44  const Filename &original_filename,
45  bool implicit_pz_file,
46  int open_flags);
47 
48  virtual bool has_file(const Filename &file) const=0;
49  virtual bool create_file(const Filename &file);
50  virtual bool make_directory(const Filename &file);
51  virtual bool delete_file(const Filename &file);
52  virtual bool rename_file(const Filename &orig_filename, const Filename &new_filename);
53  virtual bool copy_file(const Filename &orig_filename, const Filename &new_filename);
54  virtual bool is_directory(const Filename &file) const=0;
55  virtual bool is_regular_file(const Filename &file) const=0;
56  virtual bool is_writable(const Filename &file) const;
57 
58  virtual bool read_file(const Filename &file, bool do_uncompress,
59  pvector<unsigned char> &result) const;
60  virtual bool write_file(const Filename &file, bool do_compress,
61  const unsigned char *data, size_t data_size);
62 
63  virtual istream *open_read_file(const Filename &file) const=0;
64  istream *open_read_file(const Filename &file, bool do_uncompress) const;
65  virtual void close_read_file(istream *stream) const;
66 
67  virtual ostream *open_write_file(const Filename &file, bool truncate);
68  ostream *open_write_file(const Filename &file, bool do_compress, bool truncate);
69  virtual ostream *open_append_file(const Filename &file);
70  virtual void close_write_file(ostream *stream);
71 
72  virtual iostream *open_read_write_file(const Filename &file, bool truncate);
73  virtual iostream *open_read_append_file(const Filename &file);
74  virtual void close_read_write_file(iostream *stream);
75 
76  virtual streamsize get_file_size(const Filename &file, istream *stream) const=0;
77  virtual streamsize get_file_size(const Filename &file) const=0;
78  virtual time_t get_timestamp(const Filename &file) const=0;
79  virtual bool get_system_info(const Filename &file, SubfileInfo &info);
80 
81  virtual bool scan_directory(vector_string &contents,
82  const Filename &dir) const=0;
83 
84  virtual bool atomic_compare_and_exchange_contents(const Filename &file, string &orig_contents, const string &old_contents, const string &new_contents);
85  virtual bool atomic_read_contents(const Filename &file, string &contents) const;
86 
87 PUBLISHED:
88  virtual void output(ostream &out) const;
89  virtual void write(ostream &out) const;
90 
91 protected:
92  VirtualFileSystem *_file_system;
93  Filename _mount_point;
94  int _mount_flags;
95 
96 
97 public:
98  virtual TypeHandle get_type() const {
99  return get_class_type();
100  }
101  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
102  static TypeHandle get_class_type() {
103  return _type_handle;
104  }
105  static void init_type() {
106  TypedReferenceCount::init_type();
107  register_type(_type_handle, "VirtualFileMount",
108  TypedReferenceCount::get_class_type());
109  }
110 
111 private:
112  static TypeHandle _type_handle;
113 
114  friend class VirtualFileSystem;
115 };
116 
117 INLINE ostream &operator << (ostream &out, const VirtualFileMount &mount);
118 
119 #include "virtualFileMount.I"
120 
121 #endif
A hierarchy of directories and files that appears to be one continuous file system, even though the files may originate from several different sources that may not be related to the actual OS&#39;s file system.
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
The abstract base class for a file or directory within the VirtualFileSystem.
Definition: virtualFile.h:37
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
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