Changeset 247 for cpp/common/nonstd_stdio.cpp
- Timestamp:
- 11/07/14 17:51:01 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/common/nonstd_stdio.cpp
r227 r247 5 5 #include "nonstd_stdio.h" 6 6 #include "nonstd.h" 7 #include "Convert.h" //strTOwstr() 8 #include <common/stl-util.h> 7 9 8 10 #if defined _WIN32 && !defined SHP 9 11 //<unistd.h> not needed for unlink() 10 12 #include "Shlwapi.h" //PathIsRelative() 11 #include "Util.h" //strTOwstr()13 #include <sys/stat.h> //_stat 12 14 #else 13 15 #include <unistd.h> … … 23 25 } 24 26 27 bool directoryExists(const char* path) 28 { 29 struct _stat s; 30 if (_stat(path,&s)!=0) return false; 31 return S_ISDIR(s.st_mode); 32 } 33 34 bool makeDirectory(const char* path) 35 { 36 #ifdef _WIN32 37 return mkdir(path)==0; 38 #else 39 return mkdir(path,0777)==0; 40 #endif 41 } 42 43 bool makeDirectories(const char* path) 44 { 45 if (directoryExists(path)) return true; 46 string parentdir=getFileDir(path); 47 if (!makeDirectories(parentdir.c_str())) return false; 48 return makeDirectory(path); 49 } 50 51 int getFileSize(const char* path) 52 { 53 int size; 54 MFILE *f=mfopen(path,FOPEN_READ_BINARY); 55 if (f==NULL) return -1; 56 size=getFileSize(f); 57 mfclose(f); 58 return size; 59 } 60 61 int getFileSize(MFILE *f) 62 { 63 int saved_pos = mftell(f); 64 mfseek(f, 0, SEEK_END); 65 int size = mftell(f); 66 mfseek(f, saved_pos, SEEK_SET); 67 return size; 68 } 69 25 70 bool removeFile(const char* path) 26 71 { … … 35 80 return PathIsRelative(fname) == FALSE; //no wide char for old borland compiler 36 81 #else 37 return PathIsRelative( Util::strTOwstr(fname).c_str()) == FALSE; //http://msdn.microsoft.com/en-us/library/bb773660%28v=vs.85%29.aspx82 return PathIsRelative(Convert::strTOwstr(fname).c_str()) == FALSE; //http://msdn.microsoft.com/en-us/library/bb773660%28v=vs.85%29.aspx 38 83 #endif 39 84 #else
Note: See TracChangeset
for help on using the changeset viewer.