API reference Dodo 0.1.4

std/fs

Public declarations, types, methods, and source contracts for std/fs.

On this page

Library guide · API index and notation

This page is generated from the bundled library in this checkout. Signatures and adjacent source comments are reproduced below; the linked guide explains usage, storage, failures, and platform support.

import "std/fs"

Names used in signatures

Unqualified names denote this package’s types (including other source files in the same package), language built-ins, or generic parameters such as T. Qualified names use the import aliases below. These aliases belong to the library source; import a dependency yourself to use its alias in your program.

Alias Package Source file
adapter std/fs/native fs.dodo
error std/platform/error fs.dodo
io std/io fs.dodo
native std/platform/native fs.dodo
types std/fs/types fs.dodo

OpenOptions

Struct · Source

All modes are explicit. write permits overwriting at the cursor; append forces each write to the then-current end. append+truncate is invalid. exclusive requires create and never opens an already-existing path.

pub struct OpenOptions {
    pub read: bool
    pub write: bool
    pub append: bool
    pub truncate: bool
    pub create: bool
    pub exclusive: bool
    pub follow_symlinks: bool
}

OpenOptions.new

Function · Source

pub fn new() -> OpenOptions

OpenOptions.read_only

Function · Source

pub fn read_only() -> OpenOptions

OpenOptions.create_new

Function · Source

pub fn create_new() -> OpenOptions

OpenOptions.validate

Function · Source

pub fn validate(&self) -> void!error.Error

File

Struct · Source

pub struct File {
    // Private implementation fields omitted.
}

File.open

Function · Source

pub fn open(path: &native.NativeString, options: &OpenOptions) -> File!error.Error

File.open_utf8

Function · Source

UTF-8 path, no retained workspace borrow after opening.

pub fn open_utf8(path: &str, options: &OpenOptions, workspace: &mut native.Workspace) -> File!error.Error

File.read

Function · Source

pub fn read(&mut self, destination: &mut[u8]) -> usize!io.Error

File.write

Function · Source

pub fn write(&mut self, source: &[u8]) -> usize!io.Error

File.seek

Function · Source

pub fn seek(&mut self, position: usize) -> usize!io.Error

File.flush

Function · Source

File has no userspace buffering. flush is a no-op; sync requests native persistence and does not promise persistence of the containing directory.

pub fn flush(&mut self) -> void!error.Error

File.sync

Function · Source

pub fn sync(&mut self) -> void!error.Error

File.set_len

Function · Source

pub fn set_len(&mut self, length: u64) -> void!error.Error

File.close

Function · Source

pub fn close(&mut self) -> void!error.Error

File.metadata

Function · Source

pub fn metadata(&self) -> types.Metadata!error.Error

File.raw_handle

Function · Source

Access to raw numbers does not transfer ownership. Native calls and creating another owner remain unsafe; use after close is invalid.

pub fn raw_handle(&self) -> isize

File.from_raw

Function · Source

SAFETY: unique owning synchronous descriptor/HANDLE of the selected OS, correctly opened for intended operations; no other owner may close it.

pub unsafe fn from_raw(raw: isize) -> File

Requires an unsafe context. Follow the source safety preconditions and the linked guide before calling this API.

open_with_options

Function · Source

Low-level customization used by the platform extension packages. Unix mode is filtered through umask; Windows sharing bits are READ=1 WRITE=2 DELETE=4.

pub fn open_with_options(path: &native.NativeString, options: &OpenOptions, unix_mode: u32, windows_sharing: u32) -> File!error.Error

capabilities

Function · Source

pub fn capabilities() -> types.Capabilities

metadata

Function · Source

pub fn metadata(path: &native.NativeString) -> types.Metadata!error.Error

Function · Source

pub fn symlink_metadata(path: &native.NativeString) -> types.Metadata!error.Error

create_directory

Function · Source

pub fn create_directory(path: &native.NativeString) -> void!error.Error

remove_file

Function · Source

pub fn remove_file(path: &native.NativeString) -> void!error.Error

remove_directory

Function · Source

pub fn remove_directory(path: &native.NativeString) -> void!error.Error

rename

Function · Source

No copy/delete fallback. Cross-filesystem failure preserves the source.

pub fn rename(old: &native.NativeString, new: &native.NativeString, replace: bool) -> void!error.Error

set_readonly

Function · Source

pub fn set_readonly(path: &native.NativeString, readonly: bool) -> void!error.Error

Function · Source

pub fn symlink(target: &native.NativeString, path: &native.NativeString, directory: bool) -> void!error.Error

Function · Source

pub fn read_link(path: &native.NativeString, bytes: &mut[u8], wide: &mut[u16]) -> native.NativeString!error.Error from(bytes, wide)

canonicalize

Function · Source

Filesystem resolution follows links and requires existence. This is distinct from lexical normalization, which has no OS effects and cannot resolve links.

pub fn canonicalize(path: &native.NativeString, bytes: &mut[u8], wide: &mut[u16]) -> native.NativeString!error.Error from(bytes, wide)

Directory

Struct · Source

pub struct Directory {
    // Private implementation fields omitted.
}

Directory.open

Function · Source

pub fn open(path: &native.NativeString, bytes: &mut[u8], wide: &mut[u16]) -> Directory!error.Error

Directory.next

Function · Source

pub fn next(&mut self, bytes: &mut[u8], wide: &mut[u16]) -> Option<native.NativeString>!error.Error from(bytes, wide)

Directory.close

Function · Source

pub fn close(&mut self) -> void!error.Error

copy_new

Function · Source

Creates a destination exclusively and copies through explicit caller storage. Existing destinations are never truncated. A partial new file remains on failure/limit for inspection; no racy implicit unlink or rename is attempted. Permissions/times/links are not copied. limit is a hard transfer cap and eof=false explicitly distinguishes a cap from a complete copy.

pub fn copy_new(source: &native.NativeString, destination: &native.NativeString, scratch: &mut[u8], limit: usize) -> io.CopyReport!io.CopyError

FileError

Struct · Source

Progress always counts bytes retained in caller storage or accepted by the file. Native errors retain their domain/code, including open and close errors.

pub struct FileError {
    pub cause: error.Error
    pub transferred: usize
}

read_file

Function · Source

Reads from a fresh cursor. eof=false means capacity exhaustion, not success reading the whole file. Exact capacity uses a discarded one-byte EOF probe. Errors retain output[..transferred]; opening failure leaves output untouched. Concurrent writers can change the contents: this is not an atomic snapshot.

pub fn read_file(path: &str, output: &mut[u8], workspace: &mut native.Workspace) -> io.ReadReport!FileError

write_file

Function · Source

Creates a missing file; truncates an existing file to zero before writing. Follows symlinks, uses Unix 0666 filtered by umask / Windows sharing 7. Empty input still creates/truncates. No atomic replacement or sync is implied. On failure a partial/truncated file remains. Use OpenOptions.create_new() with File.open_utf8 and io.write_all for exclusive creation instead.

pub fn write_file(path: &str, input: &[u8], workspace: &mut native.Workspace) -> void!FileError

Type to search all documentation.

Keyboard shortcuts

Search documentation
Ctrl K or /
Move through results
↑ ↓
Open selected result
Enter
Close a dialog
Esc
Show these shortcuts
?