tempfile

Temporary Files and Directories

Functions

FunctionDescription
tmp_rand_suffixInternal: generate random suffix (6 alphanumeric chars).
tmp_write_prefixInternal: write “/tmp/” prefix.
tmp_nameGenerate a unique temp path name. Returns length.
tmp_make_handleHandle layout: [0]=fd, [1]=path_ptr, [2]=path_len, [3]=is_dir
tmp_fileCreate a temporary file. Returns handle.
tmp_dirCreate a temporary directory. Returns handle.
tmp_pathCopy path to dst buffer. Returns length.
tmp_fdGet file descriptor.
tmp_writeWrite bytes to temp file.
tmp_readRead bytes from temp file (seeks to start first).
tmp_closeClose the file descriptor.
tmp_removeDelete the temp file or directory.

Details

tmp_rand_suffix

fn tmp_rand_suffix(dst: &i8, off: i64) -> i64

Internal: generate random suffix (6 alphanumeric chars).

tmp_write_prefix

fn tmp_write_prefix(dst: &i8) -> i64

Internal: write “/tmp/” prefix.

tmp_name

fn tmp_name(prefix: &i8, plen: i64, dst: &i8) -> i64

Generate a unique temp path name. Returns length.

tmp_make_handle

fn tmp_make_handle(fd: i64, path: &i8, plen: i64, is_dir: i64) -> &i64

Handle layout: [0]=fd, [1]=path_ptr, [2]=path_len, [3]=is_dir

tmp_file

fn tmp_file(prefix: &i8, plen: i64) -> &i64

Create a temporary file. Returns handle.

tmp_dir

fn tmp_dir(prefix: &i8, plen: i64) -> &i64

Create a temporary directory. Returns handle.

tmp_path

fn tmp_path(handle: &i64, dst: &i8) -> i64

Copy path to dst buffer. Returns length.

tmp_fd

fn tmp_fd(handle: &i64) -> i64

Get file descriptor.

tmp_write

fn tmp_write(handle: &i64, data: &i8, len: i64) -> i64

Write bytes to temp file.

tmp_read

fn tmp_read(handle: &i64, dst: &i8, max: i64) -> i64

Read bytes from temp file (seeks to start first).

tmp_close

fn tmp_close(handle: &i64)

Close the file descriptor.

tmp_remove

fn tmp_remove(handle: &i64)

Delete the temp file or directory.