13#ifndef ML_FILE_SYSTEM_H
14#define ML_FILE_SYSTEM_H
44#include <ThirdPartyWarningsDisable.h>
47#include <ThirdPartyWarningsRestore.h>
57 #define ML_O_APPEND _O_APPEND
60 #define ML_O_BINARY _O_BINARY
63 #define ML_O_CREAT _O_CREAT
66 #define ML_O_RANDOM _O_RANDOM
69 #define ML_O_RDONLY _O_RDONLY
72 #define ML_O_RDWR _O_RDWR
75 #define ML_O_TEXT _O_TEXT
78 #define ML_O_TRUNC _O_TRUNC
81 #define ML_O_WRONLY _O_WRONLY
84 #define ML_O_LARGEFILE 0
87 #define ML_S_IWRITE _S_IWRITE
90 #define ML_S_IREAD _S_IREAD
93 #define ML_S_IEXEC _S_IEXEC
97 #define ML_S_IWUSR ML_S_IWRITE
101 #define ML_S_IRUSR ML_S_IREAD
105 #define ML_S_IXUSR ML_S_IEXEC
109 #define ML_S_IWGRP ML_S_IWRITE
113 #define ML_S_IRGRP ML_S_IREAD
117 #define ML_S_IXGRP ML_S_IEXEC
121 #define ML_S_IWOTH ML_S_IWRITE
125 #define ML_S_IROTH ML_S_IREAD
129 #define ML_S_IXOTH ML_S_IEXEC
134 #define ML_O_APPEND O_APPEND
137 #define ML_O_BINARY 0
140 #define ML_O_CREAT O_CREAT
143 #define ML_O_RANDOM O_RANDOM
146 #define ML_O_RDONLY O_RDONLY
149 #define ML_O_RDWR O_RDWR
155 #define ML_O_TRUNC O_TRUNC
158 #define ML_O_WRONLY O_WRONLY
161 #define ML_O_LARGEFILE O_LARGEFILE
164 #define ML_S_IWRITE S_IWRITE
167 #define ML_S_IREAD S_IREAD
170 #define ML_S_IEXEC S_IEXEC
174 #define ML_S_IWUSR S_IWUSR
178 #define ML_S_IRUSR S_IRUSR
182 #define ML_S_IXUSR S_IXUSR
186 #define ML_S_IWGRP S_IWGRP
190 #define ML_S_IRGRP S_IRGRP
194 #define ML_S_IXGRP S_IXGRP
198 #define ML_S_IWOTH S_IWOTH
202 #define ML_S_IROTH S_IROTH
206 #define ML_S_IXOTH S_IXOTH
313#define MLGetNonExistingRandomFileNameWithPostFix_Is_Available
MLint32 MLErrorCode
Type of an ML Error code.
ML_UTILS_EXPORT MLErrorCode MLrename(const char *oldName, const char *newName)
Renames a file with name oldName to newName.
ML_UTILS_EXPORT char * MLFileReadChunkAsStringFromDesc(int fileDescriptor, MLuint startPosition, MLuint numBytes)
Reads a string segment starting at startingPosition from the file given by fileDescriptor as a string...
ML_UTILS_EXPORT MLint MLFileGetSizeFromName(const char *fileName)
Returns the size of the file given by the null-terminated file name fileName.
ML_UTILS_EXPORT char * MLFileReadAllAsString(const char *fileName)
Reads the complete file with a fileName as a string, returns NULL on error.
ML_UTILS_EXPORT MLuint8 * MLFileReadChunkAsBinaryFromDesc(int fileDescriptor, MLuint startPosition, MLuint numBytes, int useCurrentPosition)
Reads a data segment starting at startPosition from the file given by fileDescriptor and returns NULL...
ML_UTILS_EXPORT FILE * MLfopen(const char *fileName, const char *mode)
Opens the file with name fileName with the access permissions given by mode, and returns a FILE point...
ML_UTILS_EXPORT char * MLFileReadChunkAsString(const char *fileName, MLuint startPosition, MLuint numBytes)
Reads a string segment starting at startPosition from the file given by fileName as a string and retu...
ML_UTILS_EXPORT int MLFileIsReadable(const char *fileName)
Returns 1 if the given fileName exists and is readable, 0 otherwise.
ML_UTILS_EXPORT MLuint MLFileReadChunkAsBinaryFromDescToBuffer(int fileDescriptor, MLuint8 *buffer, MLuint startPosition, MLuint numBytes)
Reads a data segment starting at startPosition from the file given by fileDescriptor and returns the ...
ML_UTILS_EXPORT MLuint8 * MLFileReadChunkAsBinary(const char *fileName, MLuint startPosition, MLuint numBytes)
Reads a data segment starting at startPosition from the file given by fileName and returns NULL on er...
ML_UTILS_EXPORT MLint MLFileGetSizeFromDescriptor(int fileDescriptor)
Returns the size of the file given by the file descriptor fileDescriptor A negative value is returned...
ML_UTILS_EXPORT MLErrorCode MLFileAppendBinaryData(const char *fileName, const MLuint8 *data, size_t numBytes)
Appends numBytes of data given by data to the file given by name fileName, creating a new file if it ...
ML_UTILS_EXPORT MLErrorCode MLFileWriteBinaryDataAt(int fileDescriptor, MLuint startPosition, const MLuint8 *data, size_t numBytes)
Overwrites a section of the file given by file descriptor fileDescriptor which must have been opened ...
ML_UTILS_EXPORT std::filesystem::path MLGetFileSystemPath(const std::string &filename)
Returns a file path object for the given filename that can be used as input for a file stream.
ML_UTILS_EXPORT int MLopen(const char *fileName, int openFlags, int pMode)
Opens the file with name fileName with the given openFlags, returns a file descriptor or -1 on error.
ML_UTILS_EXPORT char * MLGetNonExistingRandomFileName(const char *prefix)
If prefix is NULL or empty then a file name is returned which does not exist in the temp file directo...
ML_UTILS_EXPORT MLuint8 * MLFileReadAllAsBinary(const char *fileName)
Reads the complete file with a fileName as binary data, returns NULL on error.
ML_UTILS_EXPORT MLErrorCode MLFileWriteStringData(const char *fileName, const char *str)
Creates, opens, and overwrites the given file with name fileName with the given non NULL,...
ML_UTILS_EXPORT int MLFileIsWritable(const char *fileName)
Returns 1 if the given file with name fileName exists and is writable, 0 otherwise.
ML_UTILS_EXPORT char * MLGetNonExistingRandomFileNameWithPostFix(const char *prefix, const char *postFix)
Same as MLGetNonExistingRandomFileName() with the difference that the resulting unique file name also...
ML_UTILS_EXPORT MLErrorCode MLFileAppendBinaryDataWithDescriptor(int fileDescriptor, const MLuint8 *data, size_t numBytes)
Appends numBytes of data given by data to the file given by file descriptor fileDescriptor which must...
ML_UTILS_EXPORT MLint MLFileGetSizeFromFilePointer(FILE *file)
Returns the size of the file given by the FILE pointer file A negative value is returned on any error...
ML_UTILS_EXPORT void MLTranslateErrorCode(MLErrorCode *err)
Error code translation from global fileIO error code given by errno to ML error code *err if err is p...
ML_UTILS_EXPORT char * MLGetTempPath()
Returns the path to the temporary directory of the current user or NULL on failure.
ML_UTILS_EXPORT MLErrorCode MLclose(int fileDescriptor)
Closes an open file given by a the file descriptor fileDescriptor and returns ML_RESULT_OK on success...
ML_UTILS_EXPORT MLErrorCode MLFileWriteBinaryData(const char *fileName, const MLuint8 *data, size_t numBytes)
Creates, opens, and overwrites the given file with name fileName with the given data of a given numBy...
ML_UTILS_EXPORT MLint MLFileGetBytePos(int fileDescriptor)
Returns current file position of the file given by descriptor fileDescriptor; it returns the positive...
ML_UTILS_EXPORT MLErrorCode MLFileAppendStringData(const char *fileName, const char *strData)
Appends the given null-terminated string strData to the file given by name fileName,...
ML_UTILS_EXPORT MLint MLFileSetBytePos(int fileDescriptor, MLuint position)
Sets the pointer of a file given by descriptor fileDescriptor to a position and returns the positive ...
ML_UTILS_EXPORT MLErrorCode MLCreateDirectory(const char *path)
The directory path is created.
ML_UTILS_EXPORT MLErrorCode MLremove(const char *fileName)
Deletes file with name fileName.
ML_UTILS_EXPORT MLErrorCode MLfclose(FILE *file)
Closes an open file given by descriptor file and returns 0 on success and non zero values on failure.
ML_UTILS_EXPORT int MLFileExists(const char *fileName)
Returns 1 if the given with name fileName exists, 0 otherwise or if fileName is NULL.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
MLuint64 MLuint
An unsigned ML integer type with at least 64 bits used for index calculations on very large images ev...
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
#define ML_UTILS_EXPORT
Defines platform dependent DLL export macro for mlUtils.