Skip to main content

read_regular_file

Function read_regular_file 

Source
pub fn read_regular_file(
    path: &Path,
    limit: u64,
) -> Result<Vec<u8>, ReadRefusal>
Expand description

What: Read a whole regular file without following links, up to limit bytes. u64 is an unsigned 64-bit size; Result<Vec<u8>, ReadRefusal> is “the bytes, or why not”. Why: Recovery reads untrusted state: a link or a directory must be named as unsafe, and a runaway file must not be read into memory.

In TS you’d write (pseudocode):

async function readPrivateFile(path: string, limit: number): Promise<Uint8Array>; // throws ReadRefusal