FS_APIsize_tfs_sysdir(fs_sysdir_typetype,char*pDst,size_tdstCap);/* Returns the length of the string, or 0 on failure. If the return value is >= to dstCap it means the output buffer was too small. Use the returned value to know how big to make the buffer. Set pDst to NULL to calculate the required length. */
/* END fs_sysdir.h */
/* BEG fs_mktmp.h */
/* Make sure these options do not conflict with FS_NO_CREATE_DIRS. */
#define FS_MKTMP_DIR 0x0800 /* Create a temporary directory. */
#define FS_MKTMP_FILE 0x1000 /* Create a temporary file. */
FS_APIfs_resultfs_mktmp(constchar*pPrefix,char*pTmpPath,size_ttmpPathCap,intoptions);/* Returns FS_PATH_TOO_LONG if the output buffer is too small. Use FS_MKTMP_FILE to create a file and FS_MKTMP_DIR to create a directory. Use FS_MKTMP_BASE_DIR to query the system base temp folder. pPrefix should not include the name of the system's base temp directory. Do not include paths like "/tmp" in the prefix. The output path will include the system's base temp directory and the prefix. */
/* END fs_mktmp.h */
/* BEG fs.h */
/* BEG fs.h */
/* Open mode flags. */
/* Open mode flags. */
...
@@ -792,6 +1098,7 @@ FS_API fs_result fs_stream_read_to_end(fs_stream* pStream, fs_format format, con
...
@@ -792,6 +1098,7 @@ FS_API fs_result fs_stream_read_to_end(fs_stream* pStream, fs_format format, con
#define FS_APPEND (FS_WRITE | 0x0004)
#define FS_APPEND (FS_WRITE | 0x0004)
#define FS_OVERWRITE (FS_WRITE | 0x0008)
#define FS_OVERWRITE (FS_WRITE | 0x0008)
#define FS_TRUNCATE (FS_WRITE)
#define FS_TRUNCATE (FS_WRITE)
#define FS_TEMP (FS_TRUNCATE | 0x0010)
#define FS_TRANSPARENT 0x0000 /* Default. Opens a file such that archives of a known type are handled transparently. For example, "somefolder/archive.zip/file.txt" can be opened with "somefolder/file.txt" (the "archive.zip" part need not be specified). This assumes the `fs` object has been initialized with support for the relevant archive types. */
#define FS_TRANSPARENT 0x0000 /* Default. Opens a file such that archives of a known type are handled transparently. For example, "somefolder/archive.zip/file.txt" can be opened with "somefolder/file.txt" (the "archive.zip" part need not be specified). This assumes the `fs` object has been initialized with support for the relevant archive types. */
#define FS_OPAQUE 0x0010 /* When used, files inside archives cannot be opened automatically. For example, "somefolder/archive.zip/file.txt" will fail. Mounted archives work fine. */
#define FS_OPAQUE 0x0010 /* When used, files inside archives cannot be opened automatically. For example, "somefolder/archive.zip/file.txt" will fail. Mounted archives work fine. */
...
@@ -803,6 +1110,9 @@ FS_API fs_result fs_stream_read_to_end(fs_stream* pStream, fs_format format, con
...
@@ -803,6 +1110,9 @@ FS_API fs_result fs_stream_read_to_end(fs_stream* pStream, fs_format format, con
#define FS_NO_SPECIAL_DIRS 0x0200 /* When used, the presence of special directories like "." and ".." will be result in an error when opening files. */
#define FS_NO_SPECIAL_DIRS 0x0200 /* When used, the presence of special directories like "." and ".." will be result in an error when opening files. */
#define FS_NO_ABOVE_ROOT_NAVIGATION 0x0400 /* When used, navigating above the mount point with leading ".." segments will result in an error. Can be also be used with fs_path_normalize(). */
#define FS_NO_ABOVE_ROOT_NAVIGATION 0x0400 /* When used, navigating above the mount point with leading ".." segments will result in an error. Can be also be used with fs_path_normalize(). */
#define FS_LOWEST_PRIORITY 0x2000 /* Only used with mounting. When set will create the mount with a lower priority to existing mounts. */
#define FS_NO_INCREMENT_REFCOUNT 0x4000 /* Internal use only. Used with fs_open_archive_ex() internally. */
/* Garbage collection policies.*/
/* Garbage collection policies.*/
#define FS_GC_POLICY_THRESHOLD 0x0001 /* Only garbage collect unreferenced opened archives until the count is below the configured threshold. */
#define FS_GC_POLICY_THRESHOLD 0x0001 /* Only garbage collect unreferenced opened archives until the count is below the configured threshold. */
fs_result(*init)(fs*pFS,constvoid*pBackendConfig,fs_stream*pStream);/* Return 0 on success or an errno result code on error. pBackendConfig is a pointer to a backend-specific struct. The documentation for your backend will tell you how to use this. You can usually pass in NULL for this. */
fs_result(*init)(fs*pFS,constvoid*pBackendConfig,fs_stream*pStream);/* Return 0 on success or an errno result code on error. pBackendConfig is a pointer to a backend-specific struct. The documentation for your backend will tell you how to use this. You can usually pass in NULL for this. */
fs_result(*mkdir)(fs*pFS,constchar*pPath);/* This is not recursive. Return FS_SUCCESS if directory already exists. */
fs_result(*mkdir)(fs*pFS,constchar*pPath);/* This is not recursive. Return FS_SUCCESS if directory already exists. */
fs_result(*info)(fs*pFS,constchar*pPath,intopenMode,fs_file_info*pInfo);/* openMode flags can be ignored by most backends. It's primarily used by proxy of passthrough style backends. */
fs_result(*info)(fs*pFS,constchar*pPath,intopenMode,fs_file_info*pInfo);/* openMode flags can be ignored by most backends. It's primarily used by passthrough style backends. */
size_t(*file_alloc_size)(fs*pFS);
size_t(*file_alloc_size)(fs*pFS);
fs_result(*file_open)(fs*pFS,fs_stream*pStream,constchar*pFilePath,intopenMode,fs_file*pFile);/* Return 0 on success or an errno result code on error. Return ENOENT if the file does not exist. pStream will be null if the backend does not need a stream (the `pFS` object was not initialized with one). */
fs_result(*file_open)(fs*pFS,fs_stream*pStream,constchar*pFilePath,intopenMode,fs_file*pFile);/* Return 0 on success or an errno result code on error. Return FS_DOES_NOT_EXIST if the file does not exist. pStream will be null if the backend does not need a stream (the `pFS` object was not initialized with one). */
fs_result(*file_open_handle)(fs*pFS,void*hBackendFile,fs_file*pFile);/* Optional. Open a file from a file handle. Backend-specific. The format of hBackendFile will be specified by the backend. */
fs_result(*file_open_handle)(fs*pFS,void*hBackendFile,fs_file*pFile);/* Optional. Open a file from a file handle. Backend-specific. The format of hBackendFile will be specified by the backend. */
void(*file_close)(fs_file*pFile);
void(*file_close)(fs_file*pFile);
fs_result(*file_read)(fs_file*pFile,void*pDst,size_tbytesToRead,size_t*pBytesRead);/* Return 0 on success, or FS_AT_END on end of file. Only return FS_AT_END if *pBytesRead is 0. Return an errno code on error. Implementations must support reading when already at EOF, in which case FS_AT_END should be returned and *pBytesRead should be 0. */
fs_result(*file_read)(fs_file*pFile,void*pDst,size_tbytesToRead,size_t*pBytesRead);/* Return 0 on success, or FS_AT_END on end of file. Only return FS_AT_END if *pBytesRead is 0. Return an errno code on error. Implementations must support reading when already at EOF, in which case FS_AT_END should be returned and *pBytesRead should be 0. */
fs_iterator*(*next)(fs_iterator*pIterator);/* <-- Must return null when there are no more files. In this case, free_iterator must be called internally. */
fs_iterator*(*next)(fs_iterator*pIterator);/* <-- Must return null when there are no more files. In this case, free_iterator must be called internally. */
void(*free_iterator)(fs_iterator*pIterator);/* <-- Free the `fs_iterator` object here since `first` and `next` were the ones who allocated it. Also do any uninitialization routines. */
void(*free_iterator)(fs_iterator*pIterator);/* <-- Free the `fs_iterator` object here since `first` and `next` were the ones who allocated it. Also do any uninitialization routines. */
FS_APIfs_resultfs_rename(fs*pFS,constchar*pOldName,constchar*pNewName);/* Does not consider mounts. */
FS_APIfs_resultfs_mkdir(fs*pFS,constchar*pPath);/* Does not consider mounts. Returns FS_SUCCESS if directory already exists. */
FS_APIfs_resultfs_mkdir(fs*pFS,constchar*pPath,intoptions);/* Recursive. Will consider mounts unless FS_IGNORE_MOUNTS is specified. Returns FS_SUCCESS if directory already exists. */
FS_APIfs_resultfs_info(fs*pFS,constchar*pPath,intopenMode,fs_file_info*pInfo);/* openMode flags specify same options as openMode in file_open(), but FS_READ, FS_WRITE, FS_TRUNCATE, FS_APPEND, and FS_OVERWRITE are ignored. */
FS_APIfs_resultfs_info(fs*pFS,constchar*pPath,intopenMode,fs_file_info*pInfo);/* openMode flags specify same options as openMode in file_open(), but FS_READ, FS_WRITE, FS_TRUNCATE, FS_APPEND, and FS_OVERWRITE are ignored. */
FS_APIconstchar*fs_path_file_name(constchar*pPath,size_tpathLen);/* Does *not* include the null terminator. Returns an offset of pPath. Will only be null terminated if pPath is. Returns null if the path ends with a slash. */
FS_APIconstchar*fs_path_file_name(constchar*pPath,size_tpathLen);/* Does *not* include the null terminator. Returns an offset of pPath. Will only be null terminated if pPath is. Returns null if the path ends with a slash. */
FS_APIintfs_path_directory(char*pDst,size_tdstCap,constchar*pPath,size_tpathLen);/* Returns the length, or < 0 on error. pDst can be null in which case the required length will be returned. Will not include a trailing slash. */
FS_APIintfs_path_directory(char*pDst,size_tdstCap,constchar*pPath,size_tpathLen);/* Returns the length, or < 0 on error. pDst can be null in which case the required length will be returned. Will not include a trailing slash. */
FS_APIconstchar*fs_path_extension(constchar*pPath,size_tpathLen);/* Does *not* include the null terminator. Returns an offset of pPath. Will only be null terminated if pPath is. Returns null if the extension cannot be found. */
FS_APIconstchar*fs_path_extension(constchar*pPath,size_tpathLen);/* Does *not* include the null terminator. Returns an offset of pPath. Will only be null terminated if pPath is. Returns null if the extension cannot be found. */
FS_APIfs_bool32fs_path_extension_equal(constchar*pPath,size_tpathLen,constchar*pExtension,size_textensionLen);/* Returns true if the extension is equal to the given extension. Case insensitive. */
FS_APIfs_bool32fs_path_extension_equal(constchar*pPath,size_tpathLen,constchar*pExtension,size_textensionLen);/* Returns true if the extension is equal to the given extension. Case insensitive. */
FS_APIintfs_path_append(char*pDst,size_tdstCap,constchar*pBasePath,size_tbasePathLen,constchar*pPathToAppend,size_tpathToAppendLen);/* pDst can be equal to pBasePath in which case it will be appended in-place. pDst can be null in which case the function will return the required length. */
FS_APIintfs_path_append(char*pDst,size_tdstCap,constchar*pBasePath,size_tbasePathLen,constchar*pPathToAppend,size_tpathToAppendLen);/* pDst can be equal to pBasePath in which case it will be appended in-place. pDst can be null in which case the function will return the required length. */
FS_APIintfs_path_normalize(char*pDst,size_tdstCap,constchar*pPath,size_tpathLen,unsignedintoptions);/* The only root component recognized is "/". The path cannot start with "C:", "//<address>", etc. This is not intended to be a general cross-platform path normalization routine. If the path starts with "/", this will fail with a negative result code if normalization would result in the path going above the root directory. Will convert all separators to "/". Will remove trailing slash. pDst can be null in which case the required length will be returned. */
FS_APIintfs_path_normalize(char*pDst,size_tdstCap,constchar*pPath,size_tpathLen,unsignedintoptions);/* The only root component recognized is "/". The path cannot start with "C:", "//<address>", etc. This is not intended to be a general cross-platform path normalization routine. If the path starts with "/", this will fail with a negative result code if normalization would result in the path going above the root directory. Will convert all separators to "/". Will remove trailing slash. pDst can be null in which case the required length will be returned. */
/* END fs_path.h */
/* END fs_path.h */
...
@@ -1028,7 +1336,7 @@ also supports reading.
...
@@ -1028,7 +1336,7 @@ also supports reading.
You can overwrite data by seeking to the required location and then just writing like normal. To
You can overwrite data by seeking to the required location and then just writing like normal. To