← libc

libc/fs.kur

//! The file system by path, the C half of `std::fs`.
// fs.c. A path is its bytes and a NUL, with the length of the bytes; one
// holding a NUL of its own is EINVAL.

/// The errno, read at once after a call that returned NULL.
extern "C" fn kur_libc_fs_error() -> i32;
/// Frees a string a call of fs.c or env.c handed back.
extern "C" fn kur_libc_fs_release(bytes: *u8) -> ();
/// The canonical path, a string to release; or NULL.
extern "C" fn kur_libc_fs_canonicalize(path: *u8, len: usize) -> *u8;
/// stat(2), following symbolic links: 1 for a regular file, 2 for a
/// directory, 3 for anything else, with its size in `*size`; or a negative
/// errno.
extern "C" fn kur_libc_fs_stat(path: *u8, len: usize, size: *u64) -> i32;
/// remove(3): 0 or the errno.
extern "C" fn kur_libc_fs_remove(path: *u8, len: usize) -> i32;
/// rename(2): 0 or the errno.
extern "C" fn kur_libc_fs_rename(from: *u8, from_len: usize, to: *u8, to_len: usize) -> i32;
/// mkdir(2), mode 0777 less the umask: 0 or the errno.
extern "C" fn kur_libc_fs_mkdir(path: *u8, len: usize) -> i32;
/// An opaque directory handle; or NULL.
extern "C" fn kur_libc_fs_open_directory(path: *u8, len: usize) -> *u8;
/// The next entry, borrowed until the next read or close of `handle`; NULL
/// with the errno 0 at the end.
extern "C" fn kur_libc_fs_next_entry(handle: *u8) -> *u8;
/// The entry's NUL-terminated name, borrowed as the entry is.
extern "C" fn kur_libc_fs_entry_name(entry: *u8) -> *u8;
/// 1 when the entry is a directory, following symbolic links; else 0.
extern "C" fn kur_libc_fs_entry_is_directory(handle: *u8, entry: *u8) -> i32;
/// closedir(3), which consumes the handle either way: 0 or the errno.
extern "C" fn kur_libc_fs_close_directory(handle: *u8) -> i32;