Changeset 257 for cpp/common/stl-util.cpp
- Timestamp:
- 12/03/14 18:52:05 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/common/stl-util.cpp
r247 r257 11 11 #include <assert.h> 12 12 #ifdef USE_VIRTFILE 13 13 #include <frams/virtfile/virtfile.h> 14 14 #endif 15 15 #ifdef __BORLANDC__ 16 16 #define va_copy(to,from) to=from //borland does not have va_copy() at all; va_list is just a pointer in borland 17 17 #endif 18 18 … … 27 27 //almost like SString::sprintf, but there is no common code to share because SString can use its directWrite to avoid double allocating/copying 28 28 #ifdef USE_VSCPRINTF 29 va_copy(ap_copy, ap);29 va_copy(ap_copy, ap); 30 30 size = _vscprintf(format, ap_copy) + 1; //+1 for terminating null character 31 31 va_end(ap_copy); … … 36 36 buf = (char*)malloc(size); 37 37 assert(buf != NULL); 38 va_copy(ap_copy, ap);38 va_copy(ap_copy, ap); 39 39 int n = vsnprintf(buf, size, format, ap_copy); 40 40 va_end(ap_copy); … … 55 55 } 56 56 57 char* strmove(char *a, char *b) //strcpy that works well for overlapping strings ("Source and destination overlap") 58 { 59 if (a == NULL || b == NULL) 60 return NULL; 61 memmove(a, b, strlen(b) + 1); 62 return a; 63 } 64 57 65 string ssprintf(const char* format, ...) 58 66 { … … 66 74 bool readCompleteFile(const char* filename, vector<char>& data, bool warn_on_missing_file) 67 75 { 68 bool ok=false;76 bool ok = false; 69 77 #ifdef USE_VIRTFILE 70 78 if (!isAbsolutePath(filename)) 71 79 { 72 80 VirtFILE *f=Vfopen(filename,FOPEN_READ_BINARY); 73 81 if (f) 74 82 { 75 83 int size=f->getSize(); 76 84 data.resize(size); … … 78 86 ok = przeczytane == 1; 79 87 delete f; 80 }81 88 } 89 } 82 90 else 83 91 #endif 84 92 { 85 MFILE *f = mfopen(filename, FOPEN_READ_BINARY);86 if (f)87 {88 int size=getFileSize(f);89 data.resize(size);90 int przeczytane = mfread(&data[0], size, 1, f);91 mfclose(f);92 ok = przeczytane == 1;93 }93 MFILE *f = mfopen(filename, FOPEN_READ_BINARY); 94 if (f) 95 { 96 int size = getFileSize(f); 97 data.resize(size); 98 int przeczytane = mfread(&data[0], size, 1, f); 99 mfclose(f); 100 ok = przeczytane == 1; 101 } 94 102 } 95 103 if (warn_on_missing_file && !ok)
Note: See TracChangeset
for help on using the changeset viewer.