Skip to content

stdlib/fileView source ↗

file

16 items · generated by scribe fromstdlib/file.fd· synced 2026-11-15

stdlib/file16 items

Contents

file_read

Read the entire contents of a file as a string. Returns empty string if the file doesn’t exist or can’t be read.

pub fn file_read(path: str) -> str {

Parameters:

  • path: str

Returns: str

Defined at line 12


file_read_result

Read the entire contents of a file: Err(“cannot read”) when it does not exist or cannot be read.

pub fn file_read_result(path: str) -> Result<str, str> {

Parameters:

  • path: str

Returns: Result<str, str>

Defined at line 25


file_write

Write content to a file (overwrites existing content). Returns 0 on success, -1 on error.

pub fn file_write(path: str, content: str) -> i64 {

Parameters:

  • path: str
  • content: str

Returns: i64

Defined at line 38


file_append

Append content to a file (creates if it doesn’t exist). Returns 0 on success, -1 on error.

pub fn file_append(path: str, content: str) -> i64 {

Parameters:

  • path: str
  • content: str

Returns: i64

Defined at line 44


file_exists

Check if a file exists.

pub fn file_exists(path: str) -> bool {

Parameters:

  • path: str

Returns: bool

Defined at line 49


file_write_bytes

Write raw bytes to a file (binary mode). The bytes are provided as a Vec of byte values (0-255). Returns 0 on success, -1 on error. Binary-safe: p_file_write_vec uses fwrite with an explicit length, so bytes containing 0x00 are written correctly (known-bug 3.14 fix — routing through str_from_bytes + p_file_write truncated at the first NUL).

pub fn file_write_bytes(path: str, bytes: Vec<i64>) -> i64 {

Parameters:

  • path: str
  • bytes: Vec<i64>

Returns: i64

Defined at line 62


file_read_bytes

Read a file as a Vec of byte values. Returns an empty Vec if the file doesn’t exist or can’t be read. Binary-safe: p_file_read_bytes preserves bytes past a 0x00 (unlike p_file_read + str_bytes, which truncate at the first NUL).

pub fn file_read_bytes(path: str) -> Vec<i64> {

Parameters:

  • path: str

Returns: Vec<i64>

Defined at line 70


file_write_raw

Write a raw string to a file in binary mode (no newline translation). On the C backend this uses fopen(“wb”). On the interpreter it uses std::fs::write which is already binary-safe.

pub fn file_write_raw(path: str, content: str) -> i64 {

Parameters:

  • path: str
  • content: str

Returns: i64

Defined at line 77


file_delete

Delete a file. Returns 0 on success, -1 on error.

pub fn file_delete(path: str) -> i64 {

Parameters:

  • path: str

Returns: i64

Defined at line 82


file_size

Get the size of a file in bytes, or -1 if it doesn’t exist.

pub fn file_size(path: str) -> i64 {

Parameters:

  • path: str

Returns: i64

Defined at line 87


fs_read_text

Alias for fs_read_text: read file contents as a string.

pub fn fs_read_text(path: str) -> str {

Parameters:

  • path: str

Returns: str

Defined at line 95


fs_write_text

Alias for fs_write_text: write string to a file.

pub fn fs_write_text(path: str, content: str) -> i64 {

Parameters:

  • path: str
  • content: str

Returns: i64

Defined at line 100


fs_append_text

Alias for fs_append_text: append string to a file.

pub fn fs_append_text(path: str, content: str) -> i64 {

Parameters:

  • path: str
  • content: str

Returns: i64

Defined at line 105


fs_exists

Alias for fs_exists: check if a file exists.

pub fn fs_exists(path: str) -> bool {

Parameters:

  • path: str

Returns: bool

Defined at line 110


fs_delete

Alias for fs_delete: delete a file.

pub fn fs_delete(path: str) -> i64 {

Parameters:

  • path: str

Returns: i64

Defined at line 115


fs_size

Alias for fs_size: get file size in bytes.

pub fn fs_size(path: str) -> i64 {

Parameters:

  • path: str

Returns: i64

Defined at line 120


Generated by scribe, the Fides documentation generator