Crate nstd_fs

Source

Constants§

NSTD_FS_APPEND
NSTD_FS_CREATE
NSTD_FS_READ
NSTD_FS_TRUNCATE
NSTD_FS_WRITE

Functions§

nstd_fs_close
Closes a file. Parameters: NSTDFile *handle - The handle to the file.
nstd_fs_create_dir
Creates a directory with the name name. Parameters: const char *const name - The name of the directory. Returns: int errc - Nonzero on error.
nstd_fs_create_dir_all
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.
nstd_fs_dir_contents
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.
nstd_fs_dir_contents_free
Frees memory allocated by nstd_fs_dir_contents. Parameters: NSTDVec *const contents - A directory’s contents. Returns: int errc - Nonzero on error.
nstd_fs_exists
nstd_fs_free_raw
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.
nstd_fs_free_read
Frees data from nstd_fs_read. Parameters: char **contents - Pointer to the string.
nstd_fs_is_dir
nstd_fs_is_file
nstd_fs_open
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.
nstd_fs_read
Reads file into string. Parameters: NSTDFile file - The file to read from. Returns: char *contents - The file contents, null on error.
nstd_fs_read_raw
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.
nstd_fs_remove_dir
Removes an empty directory. Parameters: const char *const name - The name of the directory. Returns: int errc - Nonzero on error.
nstd_fs_remove_dir_all
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.
nstd_fs_rewind
Rewinds the stream pointer to the start of the file. Parameters: NSTDFile file - The file handle. Returns: int errc - Nonzero on error.
nstd_fs_seek
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.
nstd_fs_seek_from_end
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.
nstd_fs_seek_from_start
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.
nstd_fs_write
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 Aliases§

NSTDFile
Represents a file handle.