Skip to content

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.

js
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 ​

ts
readonly Stats: IllegalConstructor<Stats>;

Defined in: types/desktop-engine.d.ts:3521

The class of what stat returns, for instanceof

Methods ​

access() ​

ts
access(path): Promise<void>;

Defined in: types/desktop-engine.d.ts:3501

Resolves when the file or directory exists, rejects with ENOENT otherwise

Parameters ​

ParameterType
pathstring

Returns ​

Promise<void>


accessSync() ​

ts
accessSync(path): void;

Defined in: types/desktop-engine.d.ts:3502

Parameters ​

ParameterType
pathstring

Returns ​

void


appendFile() ​

ts
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 ​

ParameterType
pathstring
dataFileData
options?WriteFileOptions

Returns ​

Promise<void>


appendFileSync() ​

ts
appendFileSync(
   path, 
   data, 
   options?
): void;

Defined in: types/desktop-engine.d.ts:3491

Parameters ​

ParameterType
pathstring
dataFileData
options?WriteFileOptions

Returns ​

void


copyFile() ​

ts
copyFile(src, dest): Promise<void>;

Defined in: types/desktop-engine.d.ts:3518

Copies a file, replacing the destination

Parameters ​

ParameterType
srcstring
deststring

Returns ​

Promise<void>


copyFileSync() ​

ts
copyFileSync(src, dest): void;

Defined in: types/desktop-engine.d.ts:3519

Parameters ​

ParameterType
srcstring
deststring

Returns ​

void


existsSync() ​

ts
existsSync(path): boolean;

Defined in: types/desktop-engine.d.ts:3504

Whether the file or directory exists

Parameters ​

ParameterType
pathstring

Returns ​

boolean


mkdir() ​

ts
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 ​

ParameterType
pathstring
options?{ recursive?: boolean; }
options.recursive?boolean

Returns ​

Promise<void>


mkdirSync() ​

ts
mkdirSync(path, options?): void;

Defined in: types/desktop-engine.d.ts:3494

Parameters ​

ParameterType
pathstring
options?{ recursive?: boolean; }
options.recursive?boolean

Returns ​

void


readdir() ​

ts
readdir(path): Promise<string[]>;

Defined in: types/desktop-engine.d.ts:3496

The names in a directory, sorted

Parameters ​

ParameterType
pathstring

Returns ​

Promise<string[]>


readdirSync() ​

ts
readdirSync(path): string[];

Defined in: types/desktop-engine.d.ts:3497

Parameters ​

ParameterType
pathstring

Returns ​

string[]


readFile() ​

Call Signature ​

ts
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 ​
ParameterType
pathstring
options?| { encoding?: null; } | null
Returns ​

Promise<ArrayBuffer>

Call Signature ​

ts
readFile(path, options): Promise<string>;

Defined in: types/desktop-engine.d.ts:3483

Parameters ​
ParameterType
pathstring
options| FileEncoding | { encoding: FileEncoding; }
Returns ​

Promise<string>


readFileSync() ​

Call Signature ​

ts
readFileSync(path, options?): ArrayBuffer;

Defined in: types/desktop-engine.d.ts:3484

Parameters ​
ParameterType
pathstring
options?| { encoding?: null; } | null
Returns ​

ArrayBuffer

Call Signature ​

ts
readFileSync(path, options): string;

Defined in: types/desktop-engine.d.ts:3485

Parameters ​
ParameterType
pathstring
options| FileEncoding | { encoding: FileEncoding; }
Returns ​

string


rename() ​

ts
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 ​

ParameterType
oldPathstring
newPathstring

Returns ​

Promise<void>


renameSync() ​

ts
renameSync(oldPath, newPath): void;

Defined in: types/desktop-engine.d.ts:3516

Parameters ​

ParameterType
oldPathstring
newPathstring

Returns ​

void


rm() ​

ts
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 ​

ParameterType
pathstring
options?{ force?: boolean; recursive?: boolean; }
options.force?boolean
options.recursive?boolean

Returns ​

Promise<void>


rmdir() ​

ts
rmdir(path): Promise<void>;

Defined in: types/desktop-engine.d.ts:3509

Removes an empty directory

Parameters ​

ParameterType
pathstring

Returns ​

Promise<void>


rmdirSync() ​

ts
rmdirSync(path): void;

Defined in: types/desktop-engine.d.ts:3510

Parameters ​

ParameterType
pathstring

Returns ​

void


rmSync() ​

ts
rmSync(path, options?): void;

Defined in: types/desktop-engine.d.ts:3507

Parameters ​

ParameterType
pathstring
options?{ force?: boolean; recursive?: boolean; }
options.force?boolean
options.recursive?boolean

Returns ​

void


stat() ​

ts
stat(path): Promise<Stats>;

Defined in: types/desktop-engine.d.ts:3498

Parameters ​

ParameterType
pathstring

Returns ​

Promise<Stats>


statSync() ​

ts
statSync(path): Stats;

Defined in: types/desktop-engine.d.ts:3499

Parameters ​

ParameterType
pathstring

Returns ​

Stats


ts
unlink(path): Promise<void>;

Defined in: types/desktop-engine.d.ts:3512

Removes a file

Parameters ​

ParameterType
pathstring

Returns ​

Promise<void>


unlinkSync() ​

ts
unlinkSync(path): void;

Defined in: types/desktop-engine.d.ts:3513

Parameters ​

ParameterType
pathstring

Returns ​

void


writeFile() ​

ts
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 ​

ParameterType
pathstring
dataFileData
options?WriteFileOptions

Returns ​

Promise<void>


writeFileSync() ​

ts
writeFileSync(
   path, 
   data, 
   options?
): void;

Defined in: types/desktop-engine.d.ts:3488

Parameters ​

ParameterType
pathstring
dataFileData
options?WriteFileOptions

Returns ​

void

The SDK is released under the Apache License 2.0