/development/std/fs/index.nct
index.nct
//! Path-oriented filesystem operations.
//!
//! Whole-file functions compose the stream contracts in `std/io`. Raw target
//! paths, errno values, syscalls, and metadata layout remain in `std/internal/os`.
see ./filesystem.nct
use /string.String
use /vec.Vec
/// Portable classification of a filesystem entry.
pub enum FileType {
regular
directory
other
}
/// Portable metadata for one filesystem entry.
pub copy struct Metadata
instance Metadata {
pub method &self.file_type(): FileType
pub method &self.len(): u64
pub method &self.is_file(): bool
pub method &self.is_directory(): bool
}
/// Reads an entire file into independently owned byte storage.
pub func read(path: &str): Vec<u8>!
/// Reads an entire file and validates it as UTF-8.
pub func read_to_string(path: &str): String!
/// Creates or truncates a file and writes every supplied byte.
pub func write(path: &str, value: &[u8]): void!
/// Creates or truncates a file and writes the UTF-8 text.
pub func write_text(path: &str, text: &str): void!
/// Returns target metadata after following symbolic links.
pub func metadata(path: &str): Metadata!
/// Returns false only when the path is absent.
pub func exists(path: &str): bool!
/// Removes one non-directory entry, including a symbolic link itself.
pub func remove_file(path: &str): void!
/// Renames one entry without a copy-and-delete fallback.
pub func rename(from: &str, to: &str): void!