File handling module

File I/O operations as well as path and folder structure manipulation methods. With threading enabled, it also offers async read/write methods.

Classes

union zpl_file_descriptor
struct zpl_file_operations
struct zpl_dir_entry
struct zpl_dir_info
struct zpl_file
struct zpl_async_file
struct zpl_file_contents

Typedefs

using zpl_file_mode = zpl_u32
using zplFileModeFlag = enum zplFileModeFlag
using zplSeekWhenceType = enum zplSeekWhenceType
using zplFileError = enum zplFileError
using zpl_file_descriptor = union zpl_file_descriptor
using zpl_file_operations = struct zpl_file_operations
using zpl_file_open_proc = zplFileError(zpl_file_descriptor*fd, zpl_file_operations*ops, zpl_file_mode mode, char const*filename)
using zpl_file_read_proc = zpl_b32(zpl_file_descriptor fd, void*buffer, zpl_isize size, zpl_i64 offset, zpl_isize*bytes_read, zpl_b32 stop_at_newline)
using zpl_file_write_proc = zpl_b32(zpl_file_descriptor fd, void const*buffer, zpl_isize size, zpl_i64 offset, zpl_isize*bytes_written)
using zpl_file_seek_proc = zpl_b32(zpl_file_descriptor fd, zpl_i64 offset, zplSeekWhenceType whence, zpl_i64*new_offset)
using zpl_file_close_proc = void(zpl_file_descriptor fd)
using zpl_file_time = zpl_u64
using zpl_dir_type = enum zpl_dir_type
using zpl_dir_entry = struct zpl_dir_entry
using zpl_dir_info = struct zpl_dir_info
using zpl_file = struct zpl_file
using zpl_async_file = struct zpl_async_file
using zpl_async_file_cb = void(*)(zpl_async_file*file)
using zplFileStandardType = enum zplFileStandardType
using zpl_file_contents = struct zpl_file_contents

Functions

auto zpl_file_get_standard(zplFileStandardType std) -> zpl_file*
auto zpl_file_create(zpl_file* file, char const* filename) -> zplFileError
auto zpl_file_open(zpl_file* file, char const* filename) -> zplFileError
auto zpl_file_open_mode(zpl_file* file, zpl_file_mode mode, char const* filename) -> zplFileError
auto zpl_file_new(zpl_file* file, zpl_file_descriptor fd, zpl_file_operations ops, char const* filename) -> zplFileError
auto zpl_file_read_at_check(zpl_file* file, void* buffer, zpl_isize size, zpl_i64 offset, zpl_isize* bytes_read) -> zpl_b32
auto zpl_file_write_at_check(zpl_file* file, void const* buffer, zpl_isize size, zpl_i64 offset, zpl_isize* bytes_written) -> zpl_b32
auto zpl_file_read_at(zpl_file* file, void* buffer, zpl_isize size, zpl_i64 offset) -> zpl_b32
auto zpl_file_write_at(zpl_file* file, void const* buffer, zpl_isize size, zpl_i64 offset) -> zpl_b32
auto zpl_file_seek(zpl_file* file, zpl_i64 offset) -> zpl_i64
auto zpl_file_seek_to_end(zpl_file* file) -> zpl_i64
auto zpl_file_skip(zpl_file* file, zpl_i64 bytes) -> zpl_i64
auto zpl_file_tell(zpl_file* file) -> zpl_i64
auto zpl_file_close(zpl_file* file) -> zplFileError
auto zpl_file_read(zpl_file* file, void* buffer, zpl_isize size) -> zpl_b32
auto zpl_file_write(zpl_file* file, void const* buffer, zpl_isize size) -> zpl_b32
auto zpl_file_size(zpl_file* file) -> zpl_i64
auto zpl_file_name(zpl_file* file) -> char const *
auto zpl_file_truncate(zpl_file* file, zpl_i64 size) -> zplFileError
auto zpl_file_has_changed(zpl_file* file) -> zpl_b32
auto zpl_file_dirinfo_refresh(zpl_file* file) -> void
Refresh dirinfo of specified file.
auto zpl_async_file_read(zpl_file* file, zpl_async_file_cb proc) -> void
auto zpl_async_file_write(zpl_file* file, void const* buffer, zpl_isize size, zpl_async_file_cb proc) -> void
auto zpl_file_temp(zpl_file* file) -> zplFileError
auto zpl_file_read_contents(zpl_allocator a, zpl_b32 zero_terminate, char const* filepath) -> zpl_file_contents
auto zpl_file_free_contents(zpl_file_contents* fc) -> void
auto zpl_file_read_lines(zpl_allocator alloc, zpl_array(char*)* lines, char const* filename, zpl_b32 strip_whitespace) -> char*
Make sure you free both the returned buffer and the lines (zpl_array)
auto zpl_fs_exists(char const* filepath) -> zpl_b32
auto zpl_fs_get_type(char const* path) -> zpl_u8
auto zpl_fs_last_write_time(char const* filepath) -> zpl_file_time
auto zpl_fs_copy(char const* existing_filename, char const* new_filename, zpl_b32 fail_if_exists) -> zpl_b32
auto zpl_fs_move(char const* existing_filename, char const* new_filename) -> zpl_b32
auto zpl_fs_remove(char const* filename) -> zpl_b32
auto zpl_path_is_absolute(char const* path) -> zpl_b32
auto zpl_path_is_relative(char const* path) -> zpl_b32
auto zpl_path_is_root(char const* path) -> zpl_b32
auto zpl_path_fix_slashes(char* path) -> void
auto zpl_path_base_name(char const* path) -> char const *
auto zpl_path_extension(char const* path) -> char const *
auto zpl_path_get_full_name(zpl_allocator a, char const* path) -> char*
auto zpl_path_mkdir(char const* path, zpl_i32 mode) -> zplFileError
auto zpl_path_rmdir(char const* path) -> zplFileError
auto zpl_path_dirlist(zpl_allocator alloc, char const* dirname, zpl_b32 recurse) -> zpl_string
Returns file paths terminated by newline (
)
auto zpl_dirinfo_init(zpl_dir_info* dir, char const* path) -> void
Initialize dirinfo from specified path.
auto zpl_dirinfo_free(zpl_dir_info* dir) -> void
auto zpl_dirinfo_step(zpl_dir_entry* dir_entry) -> void
Analyze the entry's dirinfo.

Variables

zpl_file_operations const zpl_default_file_operations

Defines

#define ZPL_FILE_OPEN_PROC(name)
#define ZPL_FILE_READ_AT_PROC(name)
#define ZPL_FILE_WRITE_AT_PROC(name)
#define ZPL_FILE_SEEK_PROC(name)
#define ZPL_FILE_CLOSE_PROC(name)
#define ZPL_PATH_SEPARATOR