Constants
Functions
Closes a file.
Parameters:
NSTDFile *handle
- The handle to the file.
Creates a directory with the name name
.
Parameters:
const char *const name
- The name of the directory.
Returns: int errc
- Nonzero on error.
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 memory allocated by nstd_fs_dir_contents
.
Parameters:
NSTDVec *const contents
- A directory’s contents.
Returns: int errc
- Nonzero on error.
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.
Frees data from nstd_fs_read
.
Parameters:
char **contents
- Pointer to the string.
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 file into string.
Parameters:
NSTDFile file
- The file to read from.
Returns: char *contents
- The file contents, null on error.
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.
Removes an empty directory.
Parameters:
const char *const name
- The name of the directory.
Returns: int errc
- Nonzero on error.
Removes a directory and all of it’s contents.
Parameters:
const char *const name
- The name of the directory.
Returns: int errc
- Nonzero on error.
Rewinds the stream pointer to the start of the file.
Parameters:
NSTDFile file
- The file handle.
Returns: int errc
- Nonzero on error.
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.
Type Definitions
Represents a file handle.