Changeset 820 for cpp/common
- Timestamp:
- 10/09/18 02:00:49 (6 years ago)
- Location:
- cpp/common/virtfile
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/common/virtfile/stdiofile.cpp
r425 r820 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-201 5Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2018 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 29 29 //log_printf("Vopendir %s",path); 30 30 #ifdef __ANDROID__ 31 int resources_prefix_length =getAppResourcesDir().length();31 int resources_prefix_length = getAppResourcesDir().length(); 32 32 if (strncmp(path, getAppResourcesDir().c_str(), resources_prefix_length) == 0) //it is a resources dir 33 33 { 34 VirtDIR *vd = AndroidAPK_DIR::opendir(path +resources_prefix_length+1); //+1 because we also skip '/' and start with a "relative" dir, otherwise it does not work.34 VirtDIR *vd = AndroidAPK_DIR::opendir(path + resources_prefix_length + 1); //+1 because we also skip '/' and start with a "relative" dir, otherwise it does not work. 35 35 return vd; 36 36 } … … 51 51 } 52 52 53 bool StdioFileSystem::Vdirexists(const char* path, bool is_writable) 54 { 55 #ifdef __ANDROID__ 56 int resources_prefix_length = getAppResourcesDir().length(); 57 if (strncmp(path, getAppResourcesDir().c_str(), resources_prefix_length) == 0) //it is a resources dir 58 { 59 if (is_writable) 60 return false; 61 VirtDIR *vd = AndroidAPK_DIR::opendir(path + resources_prefix_length + 1); //+1 because we also skip '/' and start with a "relative" dir, otherwise it does not work. 62 if (vd != NULL) 63 { 64 delete vd; 65 return true; 66 } 67 else 68 { 69 return false; 70 } 71 } 72 #endif 73 return directoryExists(path, is_writable); 74 } 75 76 77 78 79 80 53 81 #ifndef NO_STD_IN_OUT_ERR 54 82 void StdioFILE::setStdio() … … 67 95 //log_printf("Vreaddir %s",dir); 68 96 #ifdef _WIN32 69 wdirent *wde =wreaddir(dir);70 if (wde ==NULL) return NULL;97 wdirent *wde = wreaddir(dir); 98 if (wde == NULL) return NULL; 71 99 strcpy(de.d_name, Convert::wstrToUtf8(wde->d_name).c_str()); 72 100 return &de; -
cpp/common/virtfile/stdiofile.h
r425 r820 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-201 5Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2018 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 17 17 VirtDIR *Vopendir(const char* path); 18 18 bool Vmkdir(const char* path) { return makeDirectory(path); } 19 bool Vdirexists(const char* path, bool is_writable) { return directoryExists(path,is_writable); }19 bool Vdirexists(const char* path, bool is_writable); 20 20 }; 21 21 … … 26 26 MFILE *file; 27 27 public: 28 StdioFILE(MFILE *f) :VirtFILE("") { file = f; }29 StdioFILE(MFILE *f, const char* p) :VirtFILE(p) { file = f; }28 StdioFILE(MFILE *f) :VirtFILE("") { file = f; } 29 StdioFILE(MFILE *f, const char* p) :VirtFILE(p) { file = f; } 30 30 #ifndef NO_STD_IN_OUT_ERR 31 31 static void setStdio(); … … 48 48 FILE *file; 49 49 public: 50 StdioFILE(FILE *f) :VirtFILE("") { file = f; }51 StdioFILE(FILE *f, const char* p) :VirtFILE(p) { file = f; }50 StdioFILE(FILE *f) :VirtFILE("") { file = f; } 51 StdioFILE(FILE *f, const char* p) :VirtFILE(p) { file = f; } 52 52 #ifndef NO_STD_IN_OUT_ERR 53 53 static void setStdio(); … … 73 73 #ifdef _WIN32 74 74 #ifdef __BORLANDC__ 75 75 typedef wDIR DIRTYPE; 76 76 #else 77 77 typedef WDIR DIRTYPE; 78 78 #endif 79 79 #else 80 80 typedef DIR DIRTYPE; 81 81 #endif 82 82 … … 111 111 }; 112 112 113 class StdioFileSystem_autoselect : public StdioFileSystem113 class StdioFileSystem_autoselect : public StdioFileSystem 114 114 { 115 115 public: 116 StdioFileSystem_autoselect()116 StdioFileSystem_autoselect() 117 117 { 118 VirtFILE::selectFileSystem(this);118 VirtFILE::selectFileSystem(this); 119 119 } 120 120 };
Note: See TracChangeset
for help on using the changeset viewer.