// This file is a part of the Framsticks GDK. // Copyright (C) 2002-2014 Maciej Komosinski and Szymon Ulatowski. See LICENSE.txt for details. // Refer to http://www.framsticks.com/ for further information. #ifndef _VIRTFILE_H_ #define _VIRTFILE_H_ #include #include #include //#include //to jest inkludowane przez powyzsze //struct dirent; //kiedys byla ta linia jak nie bylo jeszcze implementacji windowsowej dirent, ale borlandowi sie nie podoba jak są obie #ifdef DLLEXPORTACTIVE //tylko w tym pliku uzyte #define DLLEXP __declspec(dllexport) #else #define DLLEXP #endif class DLLEXP VirtFileSystem; class DLLEXP VirtFILE { public: virtual int Vread(void *ptr, size_t size, size_t nmemb)=0; virtual int Vwrite(const void *ptr, size_t size, size_t nmemb)=0; virtual int Veof()=0; virtual int Vputc(int c)=0; virtual int Vputs(const char *s)=0; virtual int Vgetc()=0; virtual int Vseek(long offset, int whence)=0; virtual int Vtell()=0; virtual void Vrewind()=0; virtual int Vflush()=0; virtual char *Vgets(char *s, int size)=0; virtual int Vprintf(const char *format, va_list args)=0; int printf(const char *format, ...); virtual const char *VgetPath() {return 0;} // 0=unspecified path virtual ~VirtFILE(); static VirtFILE *Vstdin,*Vstdout,*Vstderr; static void setVstdin(VirtFILE *); static void setVstdout(VirtFILE *); static void setVstderr(VirtFILE *); static VirtFILE* getVstdin(); static VirtFILE* getVstdout(); static VirtFILE* getVstderr(); static VirtFileSystem *vfs; static void selectFileSystem(VirtFileSystem *s); }; class DLLEXP VirtDIR { public: virtual ~VirtDIR() {} virtual dirent* Vreaddir() {return 0;} }; class DLLEXP VirtFileSystem { public: virtual VirtFILE *Vfopen(const char* path,const char*mode); virtual int Vfexists(const char* path); virtual VirtDIR *Vopendir(const char* path); }; DLLEXP VirtFILE *Vfopen(const char* path,const char*mode); DLLEXP VirtDIR *Vopendir(const char* path); DLLEXP int Vfexists(const char* path); DLLEXP int fread(void *ptr, size_t size, size_t nmemb, VirtFILE* f); DLLEXP int fwrite(const void *ptr, size_t size, size_t nmemb, VirtFILE* f); //since we want our own feof(VirtFILE*) function and some systems unfortunately define feof as a macro, we need to #undef it. Same as in virtfile.cpp #if defined _MSC_VER || defined __CYGWIN__ || defined SHP #pragma push_macro("feof") #undef feof #endif #if defined __BORLANDC__ //does not support #pragma push_macro/pop_macro #undef feof #endif DLLEXP int feof(VirtFILE* f);// {return f->Veof();} //...and then restore the original macro: #if defined _MSC_VER || defined __CYGWIN__ || defined SHP #pragma pop_macro("feof") #endif #ifdef __BORLANDC__ #define feof(__f) ((__f)->flags & _F_EOF) #endif DLLEXP int fputc(int c,VirtFILE* f); DLLEXP int fputs(const char *s,VirtFILE* f); DLLEXP int fgetc(VirtFILE* f); DLLEXP int fseek(VirtFILE* f,long offset, int whence); DLLEXP int ftell(VirtFILE* f); DLLEXP void rewind(VirtFILE* f); DLLEXP int fflush(VirtFILE* f); DLLEXP char *fgets(char *s, int size, VirtFILE* f); DLLEXP int fprintf(VirtFILE* f,const char *format, ...); DLLEXP int fclose(VirtFILE* f); DLLEXP dirent* readdir(VirtDIR* d); DLLEXP int closedir(VirtDIR* d); #endif