Creates a directory and all of it’s parents if they are missing.
Parameters:
const char *const name - The name of the directory.
Returns: int errc - Nonzero on error.
Returns a vector of all a directory’s contents.
NOTE: Memory allocated by this function should be freed with nstd_fs_dir_contents_free.
Parameters:
const char *const dir - The directory.
Returns: NSTDVec contents - The directory’s contents.
Frees raw data that has been read from a file.
Parameters:
NSTDByte **const data - The data to be freed.
const NSTDUSize size - Number of bytes to free.
Opens a file and returns the file handle. Files must be closed.
Parameters:
const char *const name - The name of the file.
const NSTDUSize mask - Bit mask defining how to open the file.
- Bit 1 - Create the file if it doesn’t exist. Write bit must be set for this to work.
- Bit 2 - Read from the file.
- Bit 3 - Write to the file.
- Bit 4 - Append to the file.
- Bit 5 - Truncate the file.
Returns: NSTDFile file - A handle to the opened file.
Reads raw data from a file.
Parameters:
NSTDFile file - The file to read from.
NSTDUSize *const size - Returns as number of bytes read.
Returns: NSTDByte *data - The raw file data.
Sets the position of the stream pointer from the current pos of the stream pointer.
Parameters:
NSTDFile file - The file handle.
long long pos - The position to set the stream pointer to.
Returns: int errc - Nonzero on error.
Sets the position of the stream pointer from the end of a file.
Parameters:
NSTDFile file - The file handle.
long long pos - The position to set the stream pointer to.
Returns: int errc - Nonzero on error.
Sets the position of the stream pointer from the start of a file.
Parameters:
NSTDFile file - The file handle.
long long pos - The position to set the stream pointer to.
Returns: int errc - Nonzero on error.
Writes a string buffer to the specified file.
Parameters:
NSTDFile file - The file to write to.
const char *const buf - The buffer to write.
Returns: int errc - Nonzero on error.