Changeset 295 for cpp/frams/virtfile/virtfile.h
- Timestamp:
- 01/15/15 22:43:01 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/virtfile/virtfile.h
r286 r295 9 9 #include <stdarg.h> 10 10 #include <common/nonstd_dir.h> 11 #include <string> 12 using std::string; 11 13 //#include <dirent.h> //to jest inkludowane przez powyzsze 12 14 //struct dirent; //kiedys byla ta linia jak nie bylo jeszcze implementacji windowsowej dirent, ale borlandowi sie nie podoba jak s¹ obie … … 22 24 class DLLEXP VirtFILE 23 25 { 26 protected: 27 string path; 24 28 public: 25 29 virtual size_t Vread(void *ptr, size_t size, size_t nmemb)=0; … … 36 40 virtual int Vprintf(const char *format, va_list args); 37 41 int printf(const char *format, ...); 38 virtual const char *VgetPath() {return 0;} // 0=unspecified path42 virtual const char *VgetPath() {return path.c_str();} 39 43 virtual int getSize(); 44 VirtFILE(const char* _path):path(_path) {} 40 45 virtual ~VirtFILE(); 41 46 static VirtFILE *Vstdin,*Vstdout,*Vstderr; … … 48 53 static VirtFileSystem *vfs; 49 54 static void selectFileSystem(VirtFileSystem *s); 55 }; 56 57 /** can be used directly or as a base class for implementations delegating VirtFILE calls to another VirtFILE object */ 58 class DLLEXP DelegatedFILE: public VirtFILE 59 { 60 VirtFILE *delegate; 61 public: 62 size_t Vread(void *ptr, size_t size, size_t nmemb) {return delegate->Vread(ptr,size,nmemb);} 63 size_t Vwrite(const void *ptr, size_t size, size_t nmemb) {return delegate->Vwrite(ptr,size,nmemb);} 64 int Veof() {return delegate->Veof();} 65 int Vputc(int c) {return delegate->Vputc(c);} 66 int Vputs(const char *s) {return delegate->Vputs(s);} 67 int Vgetc() {return delegate->Vgetc();} 68 int Vseek(long offset, int whence) {return delegate->Vseek(offset,whence);} 69 long Vtell() {return delegate->Vtell();} 70 void Vrewind() {delegate->Vrewind();} 71 int Vflush() {return delegate->Vflush();} 72 char *Vgets(char *s, int size) {return delegate->Vgets(s,size);} 73 int Vprintf(const char *format, va_list args) {return delegate->Vprintf(format,args);} 74 int getSize() {return delegate->getSize();} 75 // not overriden: VgetPath() 76 77 DelegatedFILE(const char* _path,VirtFILE *_delegate):VirtFILE(_path),delegate(_delegate) {} 78 virtual ~DelegatedFILE() {if (delegate) delete delegate; delegate=NULL;} 50 79 }; 51 80 … … 61 90 public: 62 91 virtual VirtFILE *Vfopen(const char* path,const char*mode); 63 virtual intVfexists(const char* path);92 virtual bool Vfexists(const char* path); 64 93 virtual VirtDIR *Vopendir(const char* path); 94 virtual bool Vmkdir(const char* path); 95 virtual bool Vmkdirs(const char* path); 96 virtual bool Vdirexists(const char* path,bool is_writable); 65 97 }; 98 99 /// base class for chained filesystems - redirect unimplemented calls -> chain 100 class DLLEXP ChainFileSystem : public VirtFileSystem 101 { 102 public: 103 VirtFileSystem *chain; 104 ChainFileSystem(VirtFileSystem *_chain = NULL) :chain(_chain) {} 105 VirtFILE *Vfopen(const char* path, const char*mode); 106 bool Vfexists(const char* path); 107 VirtDIR *Vopendir(const char* path); 108 bool Vmkdir(const char* path); 109 bool Vmkdirs(const char* path); 110 bool Vdirexists(const char* path,bool is_writable); 111 }; 112 66 113 67 114 DLLEXP VirtFILE *Vfopen(const char* path,const char*mode); 68 115 DLLEXP VirtDIR *Vopendir(const char* path); 69 DLLEXP int Vfexists(const char* path); 116 DLLEXP bool Vfexists(const char* path); 117 DLLEXP bool Vmkdir(const char* path); 118 DLLEXP bool Vmkdirs(const char* path); 119 DLLEXP bool Vdirexists(const char* path,bool is_writable); 70 120 71 121 DLLEXP int fread(void *ptr, size_t size, size_t nmemb, VirtFILE* f);
Note: See TracChangeset
for help on using the changeset viewer.