@zturnlibs/ztron-api


fs

Classes

FileHandle

Defined in: fs.ts:197

A scoped file handle (upstream FileHandle parity): reads/writes advance an internal cursor; close() flushes buffered writes.

Constructors

Constructor

new FileHandle(id, path): FileHandle

Defined in: fs.ts:202

Internal

— create via open.

Parameters
id

number

path

string

Returns

FileHandle

Properties

id

readonly id: number

Defined in: fs.ts:198

path

readonly path: string

Defined in: fs.ts:199

Methods

close()

close(): Promise<void>

Defined in: fs.ts:244

Flushes and releases the handle.

Returns

Promise<void>

flush()

flush(): Promise<void>

Defined in: fs.ts:239

Flushes buffered writes to disk.

Returns

Promise<void>

read()

read(length): Promise<Uint8Array<ArrayBufferLike>>

Defined in: fs.ts:208

Reads up to length bytes from the cursor (base64 on the wire).

Parameters
length

number

Returns

Promise<Uint8Array<ArrayBufferLike>>

seek()

seek(offset, whence?): Promise<number>

Defined in: fs.ts:227

whence: "start" (default) | "current" | "end".

Parameters
offset

number

whence?

"end" | "start" | "current"

Returns

Promise<number>

write()

write(data): Promise<number>

Defined in: fs.ts:217

Writes bytes at the cursor (advances it).

Parameters
data

ArrayBuffer | Uint8Array<ArrayBufferLike>

Returns

Promise<number>

Interfaces

DirEntry

Defined in: fs.ts:24

Properties

isDirectory

isDirectory: boolean

Defined in: fs.ts:26

isFile

isFile: boolean

Defined in: fs.ts:27

name

name: string

Defined in: fs.ts:25


FileMeta

Defined in: fs.ts:115

Properties

isDirectory

isDirectory: boolean

Defined in: fs.ts:117

isFile

isFile: boolean

Defined in: fs.ts:118

modifiedAt

modifiedAt: string | null

Defined in: fs.ts:119

size

size: number

Defined in: fs.ts:116


FsPathOptions

Defined in: fs.ts:9

Optional trailing options accepted by the v1 fs functions.

Properties

baseDir?

optional baseDir?: string

Defined in: fs.ts:11

Resolve a relative path against this base directory first.


MakeDirOptions

Defined in: fs.ts:77

Options for makeDir.

Properties

recursive?

optional recursive?: boolean

Defined in: fs.ts:79

Create parent directories as needed; no error if the dir exists.


OpenOptions

Defined in: fs.ts:182

Options for open.

Properties

append?

optional append?: boolean

Defined in: fs.ts:186

Position writes at EOF (implies write).

baseDir?

optional baseDir?: string

Defined in: fs.ts:190

Base directory for relative paths.

create?

optional create?: boolean

Defined in: fs.ts:188

Create the file when missing (with write/append).

read?

optional read?: boolean

Defined in: fs.ts:183

write?

optional write?: boolean

Defined in: fs.ts:184


WatchEvent

Defined in: fs.ts:138

A filesystem watch event (aligned with Tauri's watchEvent).

Properties

path

path: string

Defined in: fs.ts:143

Path of the changed entry (relative to the watched dir when the dir was watched; the file itself when a file was watched).

type

type: "modify" | "rename"

Defined in: fs.ts:140

"modify" (content change) | "rename" (create/delete/move).

Variables

fs

const fs: object

Defined in: fs.ts:164

Type Declaration

copyFile

copyFile: (path, dest) => Promise<void>

Copies a file (both source and destination must be in scope).

Parameters
path

string

dest

string

Returns

Promise<void>

exists

exists: (path, options?) => Promise<boolean>

Checks whether a path exists (out-of-scope paths report false).

Parameters
path

string

options?

FsPathOptions

Returns

Promise<boolean>

makeDir

makeDir: (path, options?) => Promise<void>

Parameters
path

string

options?

MakeDirOptions

Returns

Promise<void>

readDir

readDir: (path, options?) => Promise<DirEntry[]>

Lists a directory.

Parameters
path

string

options?

FsPathOptions

Returns

Promise<DirEntry[]>

readFile

readFile: (path) => Promise<Uint8Array<ArrayBufferLike>>

Reads a binary file; resolves with its raw bytes (raw IPC response — the injected invoke already unwraps the backend envelope).

Parameters
path

string

Returns

Promise<Uint8Array<ArrayBufferLike>>

readText

readText: (path, options?) => Promise<string>

Reads a text file (decoded as UTF-8).

Parameters
path

string

options?

FsPathOptions

Returns

Promise<string>

remove

remove: (path) => Promise<void>

Removes a file (or empty directory).

Parameters
path

string

Returns

Promise<void>

renameFile

renameFile: (path, newPath) => Promise<void>

Renames/moves a file (both paths must be in scope).

Parameters
path

string

newPath

string

Returns

Promise<void>

stat

stat: (path) => Promise<FileMeta>

Stats a file, returning size/type/last-modified.

Parameters
path

string

Returns

Promise<FileMeta>

watch

watch: (path, handler) => Promise<() => Promise<void>>

Watches a path for changes. Resolves with an unwatch function once the backend watcher is armed; events stream through handler afterwards. The path must be inside the app's fs scope (like every fs API).

Parameters
path

string

handler

(event) => void

Returns

Promise<() => Promise<void>>

writeFile

writeFile: (path, data) => Promise<void>

Writes a binary file from raw bytes (or a base64 string directly).

Parameters
path

string

data

string | Uint8Array<ArrayBufferLike>

Returns

Promise<void>

writeText

writeText: (path, contents, options?) => Promise<void>

Writes a text file.

Parameters
path

string

contents

string

options?

FsPathOptions

Returns

Promise<void>

Functions

chmod()

chmod(path, mode, options?): Promise<void>

Defined in: fs.ts:312

Changes file permission bits (unix mode).

Parameters

path

string

mode

number

options?

FsPathOptions

Returns

Promise<void>


copyFile()

copyFile(path, dest): Promise<void>

Defined in: fs.ts:123

Copies a file (both source and destination must be in scope).

Parameters

path

string

dest

string

Returns

Promise<void>


exists()

exists(path, options?): Promise<boolean>

Defined in: fs.ts:62

Checks whether a path exists (out-of-scope paths report false).

Parameters

path

string

options?

FsPathOptions

Returns

Promise<boolean>


lstat()

lstat(path, options?): Promise<{ isSymlink: boolean; mode: number; size: number; }>

Defined in: fs.ts:281

stat without following symlinks.

Parameters

path

string

options?

FsPathOptions

Returns

Promise<{ isSymlink: boolean; mode: number; size: number; }>


makeDir()

makeDir(path, options?): Promise<void>

Defined in: fs.ts:108

Parameters

path

string

options?

MakeDirOptions

Returns

Promise<void>


open()

open(path, options?): Promise<FileHandle>

Defined in: fs.ts:266

Opens a scoped file handle.

Parameters

path

string

options?

OpenOptions = {}

Returns

Promise<FileHandle>


readDir()

readDir(path, options?): Promise<DirEntry[]>

Defined in: fs.ts:52

Lists a directory.

Parameters

path

string

options?

FsPathOptions

Returns

Promise<DirEntry[]>


readFile()

readFile(path): Promise<Uint8Array<ArrayBufferLike>>

Defined in: fs.ts:85

Reads a binary file; resolves with its raw bytes (raw IPC response — the injected invoke already unwraps the backend envelope).

Parameters

path

string

Returns

Promise<Uint8Array<ArrayBufferLike>>


readLink(path, options?): Promise<string>

Defined in: fs.ts:291

Reads a symlink target.

Parameters

path

string

options?

FsPathOptions

Returns

Promise<string>


readText()

readText(path, options?): Promise<string>

Defined in: fs.ts:31

Reads a text file (decoded as UTF-8).

Parameters

path

string

options?

FsPathOptions

Returns

Promise<string>


remove()

remove(path): Promise<void>

Defined in: fs.ts:72

Removes a file (or empty directory).

Parameters

path

string

Returns

Promise<void>


renameFile()

renameFile(path, newPath): Promise<void>

Defined in: fs.ts:128

Renames/moves a file (both paths must be in scope).

Parameters

path

string

newPath

string

Returns

Promise<void>


stat()

stat(path): Promise<FileMeta>

Defined in: fs.ts:133

Stats a file, returning size/type/last-modified.

Parameters

path

string

Returns

Promise<FileMeta>


truncate()

truncate(path, length, options?): Promise<void>

Defined in: fs.ts:301

Truncates (or zero-extends) a file to length bytes.

Parameters

path

string

length

number

options?

FsPathOptions

Returns

Promise<void>


watch()

watch(path, handler): Promise<() => Promise<void>>

Defined in: fs.ts:151

Watches a path for changes. Resolves with an unwatch function once the backend watcher is armed; events stream through handler afterwards. The path must be inside the app's fs scope (like every fs API).

Parameters

path

string

handler

(event) => void

Returns

Promise<() => Promise<void>>


writeFile()

writeFile(path, data): Promise<void>

Defined in: fs.ts:90

Writes a binary file from raw bytes (or a base64 string directly).

Parameters

path

string

data

string | Uint8Array<ArrayBufferLike>

Returns

Promise<void>


writeText()

writeText(path, contents, options?): Promise<void>

Defined in: fs.ts:41

Writes a text file.

Parameters

path

string

contents

string

options?

FsPathOptions

Returns

Promise<void>