74 size_t (*
file_read)(
void *state,
void *buffer,
size_t size,
size_t count, FILE *stream);
84 size_t (*
file_write)(
void *state,
const void *ptr,
size_t size,
size_t nmemb, FILE *stream);
SyncFileSystem c_filesys()
Creates a sync file system based on the C API Uses the 64-bit options where possible (enables >2GB fi...
Represents a memory allocator Exact behavior depends on the underlying VTable used Should use the a_*...
Represents a Pseudo Random Number Generator.
Represents a Result that may have an error (error code) or a success value A type of "void" means the...
A Slice which is just a pointer + length Accessing elements through the array operator will do bounds...
VTable for synchronous file system.
Result< void, FileError >(* file_remove)(void *state, const char *path)
Function pointer for removing a file.
Result< void, FileError >(* file_rename)(void *state, const char *oldFileName, const char *newFileName)
Function pointer for renaming a file.
FileError(* file_error)(void *state, FILE *file)
Checks if a file stream has errors.
size_t(* file_read)(void *state, void *buffer, size_t size, size_t count, FILE *stream)
Function pointer for reading a file.
size_t(* file_write)(void *state, const void *ptr, size_t size, size_t nmemb, FILE *stream)
Function pointer for writing a file.
bool(* file_eof)(void *state, FILE *file)
Checks if file handle is at end of file.
Result< void, FileError >(* file_sync)(void *state, FILE *fp)
Function pointer for syncing a file to disk.
Result< void, FileError >(* file_close)(void *state, FILE *fp)
Function pointer for closing a file.
Result< FILE *, FileError >(* file_open)(void *state, const char *path, const char *mode)
Function pointer for opening a file.
size_t(* file_size)(void *state, FILE *file)
Function pointer for getting a file's size.
Synchronous File System interface for handling I/O calls This is encapsulated as a struct of file poi...
Result< Slice< char >, FileError > read_chunk_str_into(FILE *file, const Slice< char > out) const
Reads a chunk of characters from a file handle (without closing) into a buffer Uses a buffer of chars...
Result< void, FileError > write_file_safe(Allocator &tmpAlloc, const char *path, Slice< const u8 > data, Prng &prng) const
Overwrites a file's contents by first creating a temporary file and then doing a rename Will sync fil...
Result< FILE *, FileError > open(const char *path, const char *mode) const
Opens a file handle On failure, returns NULL.
Result< Slice< char >, FileError > read_file_str_into(const char *path, const Slice< char > out) const
Reads a file into a static buffer of chars (for text data).
Result< void, FileError > write_chunk(FILE *file, const Slice< const u8 > buff) const
Writes a chunk of data into a file handle (without closing) from a buffer If the entire buffer could ...
Result< void, FileError > remove(const char *path) const
Removes a file.
Result< void, FileError > read_file(Allocator &alloc, const char *path, Slice< u8 > &out) const
Reads a file into a dynamically allocated buffer and then sets out to point to that buffer.
Result< void, FileError > sync(FILE *file) const
Syncs a file to disk.
Result< void, FileError > write_file_direct(const char *path, Slice< const u8 > data) const
Overwrites a file's contents directly Will sync file to disk.
Result< void, FileError > rename(const char *oldPath, const char *newPath) const
Renames a file.
Result< void, FileError > write_chunk_str(FILE *file, const Slice< const char > buff) const
Writes a chunk of data into a file handle (without closing) from a buffer of chars (text) If the enti...
Result< void, FileError > close(FILE *file) const
Closes a file handle.
Result< Slice< u8 >, FileError > read_chunk_into(FILE *file, const Slice< u8 > out) const
Reads a chunk of characters from a file handle (without closing) into a buffer On success,...
Result< void, FileError > read_file_str(Allocator &alloc, const char *path, Slice< char > &out) const
Reads a file into a dynamically allocated buffer and then sets out to point to that buffer The buffer...
const SyncFileSystemVTable * vtable
Underlying vtable for file operations.
Result< Slice< u8 >, FileError > read_file_into(const char *path, Slice< u8 > out) const
Reads a file into a static buffer.