Panda3D
virtualFileMount.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file virtualFileMount.h
10  * @author drose
11  * @date 2002-08-03
12  */
13 
14 #ifndef VIRTUALFILEMOUNT_H
15 #define VIRTUALFILEMOUNT_H
16 
17 #include "pandabase.h"
18 
19 #include "virtualFile.h"
20 #include "filename.h"
21 #include "pointerTo.h"
22 #include "typedReferenceCount.h"
23 
24 class VirtualFileSystem;
25 
26 /**
27  * The abstract base class for a mount definition used within a
28  * VirtualFileSystem. Normally users don't need to monkey with this class
29  * directly.
30  */
31 class EXPCL_PANDA_EXPRESS VirtualFileMount : public TypedReferenceCount {
32 PUBLISHED:
33  INLINE VirtualFileMount();
34  virtual ~VirtualFileMount();
35 
36  INLINE VirtualFileSystem *get_file_system() const;
37  INLINE const Filename &get_mount_point() const;
38  INLINE int get_mount_flags() const;
39 
40 public:
41  virtual PT(VirtualFile) make_virtual_file(const Filename &local_filename,
42  const Filename &original_filename,
43  bool implicit_pz_file,
44  int open_flags);
45 
46  virtual bool has_file(const Filename &file) const=0;
47  virtual bool create_file(const Filename &file);
48  virtual bool make_directory(const Filename &file);
49  virtual bool delete_file(const Filename &file);
50  virtual bool rename_file(const Filename &orig_filename, const Filename &new_filename);
51  virtual bool copy_file(const Filename &orig_filename, const Filename &new_filename);
52  virtual bool is_directory(const Filename &file) const=0;
53  virtual bool is_regular_file(const Filename &file) const=0;
54  virtual bool is_writable(const Filename &file) const;
55 
56  virtual bool read_file(const Filename &file, bool do_uncompress,
57  vector_uchar &result) const;
58  virtual bool write_file(const Filename &file, bool do_compress,
59  const unsigned char *data, size_t data_size);
60 
61  virtual std::istream *open_read_file(const Filename &file) const=0;
62  std::istream *open_read_file(const Filename &file, bool do_uncompress) const;
63  virtual void close_read_file(std::istream *stream) const;
64 
65  virtual std::ostream *open_write_file(const Filename &file, bool truncate);
66  std::ostream *open_write_file(const Filename &file, bool do_compress, bool truncate);
67  virtual std::ostream *open_append_file(const Filename &file);
68  virtual void close_write_file(std::ostream *stream);
69 
70  virtual std::iostream *open_read_write_file(const Filename &file, bool truncate);
71  virtual std::iostream *open_read_append_file(const Filename &file);
72  virtual void close_read_write_file(std::iostream *stream);
73 
74  virtual std::streamsize get_file_size(const Filename &file, std::istream *stream) const=0;
75  virtual std::streamsize get_file_size(const Filename &file) const=0;
76  virtual time_t get_timestamp(const Filename &file) const=0;
77  virtual bool get_system_info(const Filename &file, SubfileInfo &info);
78 
79  virtual bool scan_directory(vector_string &contents,
80  const Filename &dir) const=0;
81 
82  virtual bool atomic_compare_and_exchange_contents(const Filename &file, std::string &orig_contents, const std::string &old_contents, const std::string &new_contents);
83  virtual bool atomic_read_contents(const Filename &file, std::string &contents) const;
84 
85 PUBLISHED:
86  virtual void output(std::ostream &out) const;
87  virtual void write(std::ostream &out) const;
88 
89 protected:
90  VirtualFileSystem *_file_system;
91  Filename _mount_point;
92  int _mount_flags;
93 
94 
95 public:
96  virtual TypeHandle get_type() const {
97  return get_class_type();
98  }
99  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
100  static TypeHandle get_class_type() {
101  return _type_handle;
102  }
103  static void init_type() {
104  TypedReferenceCount::init_type();
105  register_type(_type_handle, "VirtualFileMount",
106  TypedReferenceCount::get_class_type());
107  }
108 
109 private:
110  static TypeHandle _type_handle;
111 
112  friend class VirtualFileSystem;
113 };
114 
115 INLINE std::ostream &operator << (std::ostream &out, const VirtualFileMount &mount);
116 
117 #include "virtualFileMount.I"
118 
119 #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.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(), along with zero to four record_derivation()s.
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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:35
bool mount(Multifile *multifile, const Filename &mount_point, int flags)
Mounts the indicated Multifile at the given mount point.
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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:26
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.