Interface: FileSystem
Defined in: types/desktop-engine.d.ts:3480
The file system, DesktopEngine.fs: the functions of Node's fs/promises and their Sync versions. The asynchronous ones run one at a time in order, off the JavaScript thread; they reject with a FileSystemError, the Sync ones throw it. Binary data is an ArrayBuffer.
const fs = DesktopEngine.fs;
await fs.mkdir('defile://usr/notes', { recursive: true });
await fs.writeFile('defile://usr/notes/today.json', JSON.stringify(note));
const text = await fs.readFile('defile://usr/notes/today.json', 'utf8');Properties
Stats
readonly Stats: IllegalConstructor<Stats>;Defined in: types/desktop-engine.d.ts:3521
The class of what stat returns, for instanceof
Methods
access()
access(path): Promise<void>;Defined in: types/desktop-engine.d.ts:3501
Resolves when the file or directory exists, rejects with ENOENT otherwise
Parameters
| Parameter | Type |
|---|---|
path | string |
Returns
Promise<void>
accessSync()
accessSync(path): void;Defined in: types/desktop-engine.d.ts:3502
Parameters
| Parameter | Type |
|---|---|
path | string |
Returns
void
appendFile()
appendFile(
path,
data,
options?
): Promise<void>;Defined in: types/desktop-engine.d.ts:3490
Adds to the end of the file, making it when it doesn't exist
Parameters
| Parameter | Type |
|---|---|
path | string |
data | FileData |
options? | WriteFileOptions |
Returns
Promise<void>
appendFileSync()
appendFileSync(
path,
data,
options?
): void;Defined in: types/desktop-engine.d.ts:3491
Parameters
| Parameter | Type |
|---|---|
path | string |
data | FileData |
options? | WriteFileOptions |
Returns
void
copyFile()
copyFile(src, dest): Promise<void>;Defined in: types/desktop-engine.d.ts:3518
Copies a file, replacing the destination
Parameters
| Parameter | Type |
|---|---|
src | string |
dest | string |
Returns
Promise<void>
copyFileSync()
copyFileSync(src, dest): void;Defined in: types/desktop-engine.d.ts:3519
Parameters
| Parameter | Type |
|---|---|
src | string |
dest | string |
Returns
void
existsSync()
existsSync(path): boolean;Defined in: types/desktop-engine.d.ts:3504
Whether the file or directory exists
Parameters
| Parameter | Type |
|---|---|
path | string |
Returns
boolean
mkdir()
mkdir(path, options?): Promise<void>;Defined in: types/desktop-engine.d.ts:3493
Makes a directory; with recursive also its missing parents, and it's no error when it exists
Parameters
| Parameter | Type |
|---|---|
path | string |
options? | { recursive?: boolean; } |
options.recursive? | boolean |
Returns
Promise<void>
mkdirSync()
mkdirSync(path, options?): void;Defined in: types/desktop-engine.d.ts:3494
Parameters
| Parameter | Type |
|---|---|
path | string |
options? | { recursive?: boolean; } |
options.recursive? | boolean |
Returns
void
readdir()
readdir(path): Promise<string[]>;Defined in: types/desktop-engine.d.ts:3496
The names in a directory, sorted
Parameters
| Parameter | Type |
|---|---|
path | string |
Returns
Promise<string[]>
readdirSync()
readdirSync(path): string[];Defined in: types/desktop-engine.d.ts:3497
Parameters
| Parameter | Type |
|---|---|
path | string |
Returns
string[]
readFile()
Call Signature
readFile(path, options?): Promise<ArrayBuffer>;Defined in: types/desktop-engine.d.ts:3482
Reads a file: an ArrayBuffer, or a string with an encoding
Parameters
| Parameter | Type |
|---|---|
path | string |
options? | | { encoding?: null; } | null |
Returns
Promise<ArrayBuffer>
Call Signature
readFile(path, options): Promise<string>;Defined in: types/desktop-engine.d.ts:3483
Parameters
| Parameter | Type |
|---|---|
path | string |
options | | FileEncoding | { encoding: FileEncoding; } |
Returns
Promise<string>
readFileSync()
Call Signature
readFileSync(path, options?): ArrayBuffer;Defined in: types/desktop-engine.d.ts:3484
Parameters
| Parameter | Type |
|---|---|
path | string |
options? | | { encoding?: null; } | null |
Returns
ArrayBuffer
Call Signature
readFileSync(path, options): string;Defined in: types/desktop-engine.d.ts:3485
Parameters
| Parameter | Type |
|---|---|
path | string |
options | | FileEncoding | { encoding: FileEncoding; } |
Returns
string
rename()
rename(oldPath, newPath): Promise<void>;Defined in: types/desktop-engine.d.ts:3515
Moves or renames a file or a directory, replacing a file at the new path
Parameters
| Parameter | Type |
|---|---|
oldPath | string |
newPath | string |
Returns
Promise<void>
renameSync()
renameSync(oldPath, newPath): void;Defined in: types/desktop-engine.d.ts:3516
Parameters
| Parameter | Type |
|---|---|
oldPath | string |
newPath | string |
Returns
void
rm()
rm(path, options?): Promise<void>;Defined in: types/desktop-engine.d.ts:3506
Removes a file, or a directory with recursive; force ignores a missing one
Parameters
| Parameter | Type |
|---|---|
path | string |
options? | { force?: boolean; recursive?: boolean; } |
options.force? | boolean |
options.recursive? | boolean |
Returns
Promise<void>
rmdir()
rmdir(path): Promise<void>;Defined in: types/desktop-engine.d.ts:3509
Removes an empty directory
Parameters
| Parameter | Type |
|---|---|
path | string |
Returns
Promise<void>
rmdirSync()
rmdirSync(path): void;Defined in: types/desktop-engine.d.ts:3510
Parameters
| Parameter | Type |
|---|---|
path | string |
Returns
void
rmSync()
rmSync(path, options?): void;Defined in: types/desktop-engine.d.ts:3507
Parameters
| Parameter | Type |
|---|---|
path | string |
options? | { force?: boolean; recursive?: boolean; } |
options.force? | boolean |
options.recursive? | boolean |
Returns
void
stat()
stat(path): Promise<Stats>;Defined in: types/desktop-engine.d.ts:3498
Parameters
| Parameter | Type |
|---|---|
path | string |
Returns
Promise<Stats>
statSync()
statSync(path): Stats;Defined in: types/desktop-engine.d.ts:3499
Parameters
| Parameter | Type |
|---|---|
path | string |
Returns
unlink()
unlink(path): Promise<void>;Defined in: types/desktop-engine.d.ts:3512
Removes a file
Parameters
| Parameter | Type |
|---|---|
path | string |
Returns
Promise<void>
unlinkSync()
unlinkSync(path): void;Defined in: types/desktop-engine.d.ts:3513
Parameters
| Parameter | Type |
|---|---|
path | string |
Returns
void
writeFile()
writeFile(
path,
data,
options?
): Promise<void>;Defined in: types/desktop-engine.d.ts:3487
Replaces the file (all at once: it's never left half written), making it when it doesn't exist; its directory must exist
Parameters
| Parameter | Type |
|---|---|
path | string |
data | FileData |
options? | WriteFileOptions |
Returns
Promise<void>
writeFileSync()
writeFileSync(
path,
data,
options?
): void;Defined in: types/desktop-engine.d.ts:3488
Parameters
| Parameter | Type |
|---|---|
path | string |
data | FileData |
options? | WriteFileOptions |
Returns
void
