Panda3D
virtualFileMountSystem.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 virtualFileMountSystem.h
10  * @author drose
11  * @date 2002-08-03
12  */
13 
14 #ifndef VIRTUALFILEMOUNTSYSTEM_H
15 #define VIRTUALFILEMOUNTSYSTEM_H
16 
17 #include "pandabase.h"
18 
19 #include "virtualFileMount.h"
20 
21 /**
22  * Maps an actual OS directory into the VirtualFileSystem.
23  */
24 class EXPCL_PANDA_EXPRESS VirtualFileMountSystem : public VirtualFileMount {
25 PUBLISHED:
26  INLINE VirtualFileMountSystem(const Filename &physical_filename);
27 
28  INLINE const Filename &get_physical_filename() const;
29 
30 public:
31  virtual bool has_file(const Filename &file) const;
32  virtual bool create_file(const Filename &file);
33  virtual bool make_directory(const Filename &file);
34  virtual bool delete_file(const Filename &file);
35  virtual bool rename_file(const Filename &orig_filename, const Filename &new_filename);
36  virtual bool copy_file(const Filename &orig_filename, const Filename &new_filename);
37  virtual bool is_directory(const Filename &file) const;
38  virtual bool is_regular_file(const Filename &file) const;
39  virtual bool is_writable(const Filename &file) const;
40 
41  virtual std::istream *open_read_file(const Filename &file) const;
42  virtual std::ostream *open_write_file(const Filename &file, bool truncate);
43  virtual std::ostream *open_append_file(const Filename &file);
44  virtual std::iostream *open_read_write_file(const Filename &file, bool truncate);
45  virtual std::iostream *open_read_append_file(const Filename &file);
46 
47  virtual std::streamsize get_file_size(const Filename &file, std::istream *stream) const;
48  virtual std::streamsize get_file_size(const Filename &file) const;
49  virtual time_t get_timestamp(const Filename &file) const;
50  virtual bool get_system_info(const Filename &file, SubfileInfo &info);
51 
52  virtual bool scan_directory(vector_string &contents,
53  const Filename &dir) const;
54 
55  virtual bool atomic_compare_and_exchange_contents(const Filename &file, std::string &orig_contents, const std::string &old_contents, const std::string &new_contents);
56  virtual bool atomic_read_contents(const Filename &file, std::string &contents) const;
57 
58  virtual void output(std::ostream &out) const;
59 
60 private:
61  Filename _physical_filename;
62 
63 public:
64  virtual TypeHandle get_type() const {
65  return get_class_type();
66  }
67  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
68  static TypeHandle get_class_type() {
69  return _type_handle;
70  }
71  static void init_type() {
72  VirtualFileMount::init_type();
73  register_type(_type_handle, "VirtualFileMountSystem",
74  VirtualFileMount::get_class_type());
75  }
76 
77 private:
78  static TypeHandle _type_handle;
79 };
80 
81 #include "virtualFileMountSystem.I"
82 
83 #endif
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.
Maps an actual OS directory into the VirtualFileSystem.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
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.
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:39
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.
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.
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:26
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
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.