Panda3D

virtualFileSimple.h

00001 // Filename: virtualFileSimple.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 VIRTUALFILESIMPLE_H
00016 #define VIRTUALFILESIMPLE_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "virtualFile.h"
00021 
00022 ////////////////////////////////////////////////////////////////////
00023 //       Class : VirtualFileSimple
00024 // Description : A simple file or directory within the
00025 //               VirtualFileSystem: this maps to exactly one file on
00026 //               one mount point.  Most directories, and all regular
00027 //               files, are of this kind.
00028 ////////////////////////////////////////////////////////////////////
00029 class EXPCL_PANDAEXPRESS VirtualFileSimple : public VirtualFile {
00030 public:
00031   INLINE VirtualFileSimple(VirtualFileMount *mount,
00032                            const Filename &local_filename,
00033                            bool implicit_pz_file);
00034 
00035 PUBLISHED:
00036   virtual VirtualFileSystem *get_file_system() const;
00037   INLINE VirtualFileMount *get_mount() const;
00038   virtual Filename get_filename() const;
00039 
00040   virtual bool has_file() const;
00041   virtual bool is_directory() const;
00042   virtual bool is_regular_file() const;
00043   INLINE bool is_implicit_pz_file() const;
00044 
00045   virtual istream *open_read_file(bool auto_unwrap) const;
00046   virtual off_t get_file_size(istream *stream) const;
00047   virtual off_t get_file_size() const;
00048   virtual time_t get_timestamp() const;
00049 
00050 public:
00051   virtual bool read_file(pvector<unsigned char> &result, bool auto_unwrap) const;
00052 
00053 protected:
00054   virtual bool scan_local_directory(VirtualFileList *file_list, 
00055                                     const ov_set<string> &mount_points) const;
00056 
00057 private:
00058   VirtualFileMount *_mount;
00059   Filename _local_filename;
00060   bool _implicit_pz_file;
00061 
00062 public:
00063   virtual TypeHandle get_type() const {
00064     return get_class_type();
00065   }
00066   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00067 
00068 PUBLISHED:
00069   static TypeHandle get_class_type() {
00070     return _type_handle;
00071   }
00072 
00073 public:
00074   static void init_type() {
00075     VirtualFile::init_type();
00076     register_type(_type_handle, "VirtualFileSimple",
00077                   VirtualFile::get_class_type());
00078   }
00079 
00080 private:
00081   static TypeHandle _type_handle;
00082 };
00083 
00084 #include "virtualFileSimple.I"
00085 
00086 #endif
 All Classes Functions Variables Enumerations