Panda3D
|
00001 // Filename: virtualFileMountSystem.h 00002 // Created by: drose (03Aug02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef VIRTUALFILEMOUNTSYSTEM_H 00016 #define VIRTUALFILEMOUNTSYSTEM_H 00017 00018 #include "pandabase.h" 00019 00020 #include "virtualFileMount.h" 00021 00022 //////////////////////////////////////////////////////////////////// 00023 // Class : VirtualFileMountSystem 00024 // Description : Maps an actual OS directory into the 00025 // VirtualFileSystem. 00026 //////////////////////////////////////////////////////////////////// 00027 class EXPCL_PANDAEXPRESS VirtualFileMountSystem : public VirtualFileMount { 00028 PUBLISHED: 00029 INLINE VirtualFileMountSystem(const Filename &physical_filename); 00030 00031 INLINE const Filename &get_physical_filename() const; 00032 00033 public: 00034 virtual bool has_file(const Filename &file) const; 00035 virtual bool create_file(const Filename &file); 00036 virtual bool make_directory(const Filename &file); 00037 virtual bool delete_file(const Filename &file); 00038 virtual bool rename_file(const Filename &orig_filename, const Filename &new_filename); 00039 virtual bool copy_file(const Filename &orig_filename, const Filename &new_filename); 00040 virtual bool is_directory(const Filename &file) const; 00041 virtual bool is_regular_file(const Filename &file) const; 00042 virtual bool is_writable(const Filename &file) const; 00043 00044 virtual istream *open_read_file(const Filename &file) const; 00045 virtual ostream *open_write_file(const Filename &file, bool truncate); 00046 virtual ostream *open_append_file(const Filename &file); 00047 virtual iostream *open_read_write_file(const Filename &file, bool truncate); 00048 virtual iostream *open_read_append_file(const Filename &file); 00049 00050 virtual off_t get_file_size(const Filename &file, istream *stream) const; 00051 virtual off_t get_file_size(const Filename &file) const; 00052 virtual time_t get_timestamp(const Filename &file) const; 00053 virtual bool get_system_info(const Filename &file, SubfileInfo &info); 00054 00055 virtual bool scan_directory(vector_string &contents, 00056 const Filename &dir) const; 00057 00058 virtual bool atomic_compare_and_exchange_contents(const Filename &file, string &orig_contents, const string &old_contents, const string &new_contents); 00059 virtual bool atomic_read_contents(const Filename &file, string &contents) const; 00060 00061 virtual void output(ostream &out) const; 00062 00063 private: 00064 Filename _physical_filename; 00065 00066 public: 00067 virtual TypeHandle get_type() const { 00068 return get_class_type(); 00069 } 00070 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00071 static TypeHandle get_class_type() { 00072 return _type_handle; 00073 } 00074 static void init_type() { 00075 VirtualFileMount::init_type(); 00076 register_type(_type_handle, "VirtualFileMountSystem", 00077 VirtualFileMount::get_class_type()); 00078 } 00079 00080 private: 00081 static TypeHandle _type_handle; 00082 }; 00083 00084 #include "virtualFileMountSystem.I" 00085 00086 #endif