ML Reference
|
00001 // **InsertLicense** code 00002 //---------------------------------------------------------------------------------- 00029 00034 //---------------------------------------------------------------------------------- 00035 #ifndef __mlFileSystem_H 00036 #define __mlFileSystem_H 00037 00038 #ifndef __mlUtilsSystem_H 00039 #include "mlUtilsSystem.h" 00040 #endif 00041 00043 #include "mlSystemWarningsDisable.h" 00044 #include <fcntl.h> 00045 #include <sys/stat.h> 00046 #include "mlSystemWarningsRestore.h" 00047 00050 #ifdef WIN32 00051 00053 #define ML_O_APPEND _O_APPEND 00054 00056 #define ML_O_BINARY _O_BINARY 00057 00059 #define ML_O_CREAT _O_CREAT 00060 00062 #define ML_O_RANDOM _O_RANDOM 00063 00065 #define ML_O_RDONLY _O_RDONLY 00066 00068 #define ML_O_RDWR _O_RDWR 00069 00071 #define ML_O_TEXT _O_TEXT 00072 00074 #define ML_O_TRUNC _O_TRUNC 00075 00077 #define ML_O_WRONLY _O_WRONLY 00078 00080 #define ML_O_LARGEFILE 0 00081 00083 #define ML_S_IREAD _S_IREAD 00084 00086 #define ML_S_IWRITE _S_IWRITE 00087 00088 #else 00089 00091 #define ML_O_APPEND O_APPEND 00092 00094 #define ML_O_BINARY 0 00095 00097 #define ML_O_CREAT O_CREAT 00098 00100 #define ML_O_RANDOM O_RANDOM 00101 00103 #define ML_O_RDONLY O_RDONLY 00104 00106 #define ML_O_RDWR O_RDWR 00107 00109 #define ML_O_TEXT 0 00110 00112 #define ML_O_TRUNC O_TRUNC 00113 00115 #define ML_O_WRONLY O_WRONLY 00116 00117 #if defined(MACOS) 00118 00119 #define ML_O_LARGEFILE 0 00120 #else 00121 00122 #define ML_O_LARGEFILE O_LARGEFILE 00123 #endif 00124 00126 #define ML_S_IREAD S_IREAD 00127 00129 #define ML_S_IWRITE S_IWRITE 00130 #endif 00131 00132 00141 ML_UTILS_EXPORT void MLTranslateErrorCode(MLErrorCode *err); 00142 00143 00144 //------------------------------------------------------------------------- 00146 00147 00148 00149 //------------------------------------------------------------------------- 00150 00159 ML_UTILS_EXPORT FILE* MLfopen(const char *fileName, 00160 const char *mode) ML_RETURN_VALUE_SHOULD_BE_USED; 00161 00167 ML_UTILS_EXPORT MLErrorCode MLfclose(FILE *file); 00168 00173 ML_UTILS_EXPORT MLErrorCode MLremove(const char *fileName); 00174 00180 ML_UTILS_EXPORT MLErrorCode MLrename(const char *oldName, 00181 const char *newName); 00182 00193 ML_UTILS_EXPORT int MLopen(const char *fileName, 00194 int openFlags, 00195 int pMode) ML_RETURN_VALUE_SHOULD_BE_USED; 00196 00200 ML_UTILS_EXPORT MLErrorCode MLclose(int fileDescriptor); 00201 00206 ML_UTILS_EXPORT int MLFileExists(const char *fileName); 00207 00211 ML_UTILS_EXPORT char *MLGetTempPath() ML_RETURN_VALUE_SHOULD_BE_USED; 00212 00227 ML_UTILS_EXPORT char *MLGetNonExistingRandomFileName(const char *prefix) ML_RETURN_VALUE_SHOULD_BE_USED; 00228 00229 // Tag to idetify whether MLGetNonExistingRandomFileNameWithPostFix exists to avoid 00230 // failing mainline builds. To be removed after merge to trunk. 00231 #define MLGetNonExistingRandomFileNameWithPostFix_Is_Available 00232 00237 ML_UTILS_EXPORT char *MLGetNonExistingRandomFileNameWithPostFix(const char *prefix, const char *postFix) ML_RETURN_VALUE_SHOULD_BE_USED; 00238 00243 ML_UTILS_EXPORT int MLFileIsReadable(const char *fileName); 00244 00249 ML_UTILS_EXPORT int MLFileIsWritable(const char *fileName); 00250 00257 ML_UTILS_EXPORT MLErrorCode MLFileWriteStringData(const char *fileName, 00258 const char *str) ML_RETURN_VALUE_SHOULD_BE_USED; 00259 00265 ML_UTILS_EXPORT MLErrorCode MLFileWriteBinaryData(const char *fileName, 00266 const MLuint8 *data, 00267 size_t numBytes) ML_RETURN_VALUE_SHOULD_BE_USED; 00268 00275 ML_UTILS_EXPORT MLErrorCode MLFileWriteBinaryDataAt(int fileDescriptor, 00276 MLuint startPosition, 00277 const MLuint8 *data, 00278 size_t numBytes) ML_RETURN_VALUE_SHOULD_BE_USED; 00279 00285 ML_UTILS_EXPORT MLErrorCode MLFileAppendStringData(const char *fileName, 00286 const char *strData) ML_RETURN_VALUE_SHOULD_BE_USED; 00287 00293 ML_UTILS_EXPORT MLErrorCode MLFileAppendBinaryData(const char *fileName, 00294 const MLuint8 *data, 00295 size_t numBytes) ML_RETURN_VALUE_SHOULD_BE_USED; 00296 00301 ML_UTILS_EXPORT MLErrorCode MLFileAppendBinaryDataWithDescriptor(int fileDescriptor, 00302 const MLuint8 *data, 00303 size_t numBytes) ML_RETURN_VALUE_SHOULD_BE_USED; 00304 00310 ML_UTILS_EXPORT char* MLFileReadAllAsString(const char *fileName) ML_RETURN_VALUE_SHOULD_BE_USED; 00311 00316 ML_UTILS_EXPORT MLuint8* MLFileReadAllAsBinary(const char *fileName) ML_RETURN_VALUE_SHOULD_BE_USED; 00317 00333 ML_UTILS_EXPORT char* MLFileReadChunkAsString(const char *fileName, 00334 MLuint startPosition, 00335 MLuint numBytes) ML_RETURN_VALUE_SHOULD_BE_USED; 00336 00349 ML_UTILS_EXPORT MLuint8* MLFileReadChunkAsBinary(const char *fileName, 00350 MLuint startPosition, 00351 MLuint numBytes) ML_RETURN_VALUE_SHOULD_BE_USED; 00352 00369 ML_UTILS_EXPORT MLuint8* MLFileReadChunkAsBinaryFromDesc(int fileDescriptor, 00370 MLuint startPosition, 00371 MLuint numBytes, 00372 int useCurrentPosition) ML_RETURN_VALUE_SHOULD_BE_USED; 00373 00390 ML_UTILS_EXPORT char* MLFileReadChunkAsStringFromDesc(int fileDescriptor, 00391 MLuint startPosition, 00392 MLuint numBytes) ML_RETURN_VALUE_SHOULD_BE_USED; 00393 00394 00399 ML_UTILS_EXPORT MLint MLFileGetSizeFromDescriptor(int fileDescriptor); 00400 00406 ML_UTILS_EXPORT MLint MLFileGetSizeFromName(const char* fileName); 00407 00413 ML_UTILS_EXPORT MLint MLFileSetBytePos(int fileDescriptor, 00414 MLuint position) ML_RETURN_VALUE_SHOULD_BE_USED; 00415 00420 ML_UTILS_EXPORT MLint MLFileGetBytePos(int fileDescriptor) ML_RETURN_VALUE_SHOULD_BE_USED; 00421 00426 ML_UTILS_EXPORT MLErrorCode MLCreateDirectory(const char *path) ML_RETURN_VALUE_SHOULD_BE_USED; 00427 00429 00430 00431 00432 #endif // __mlFileSystem_H