Skip to content

Interface: FileSystem ​

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

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:4525

The class of what stat returns, for instanceof

Methods ​

access() ​

ts
access(path): Promise<void>;

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

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:4506

Parameters ​

ParameterType
pathstring

Returns ​

void


appendFile() ​

ts
appendFile(
   path, 
   data, 
   options?
): Promise<void>;

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

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:4495

Parameters ​

ParameterType
pathstring
dataFileData
options?WriteFileOptions

Returns ​

void


copyFile() ​

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

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

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:4523

Parameters ​

ParameterType
srcstring
deststring

Returns ​

void


existsSync() ​

ts
existsSync(path): boolean;

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

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:4497

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:4498

Parameters ​

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

Returns ​

void


readdir() ​

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

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

The names in a directory, sorted

Parameters ​

ParameterType
pathstring

Returns ​

Promise<string[]>


readdirSync() ​

ts
readdirSync(path): string[];

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

Parameters ​

ParameterType
pathstring

Returns ​

string[]


readFile() ​

Call Signature ​

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

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

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:4487

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:4488

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

ArrayBuffer

Call Signature ​

ts
readFileSync(path, options): string;

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

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

string


rename() ​

ts
rename(oldPath, newPath): Promise<void>;

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

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:4520

Parameters ​

ParameterType
oldPathstring
newPathstring

Returns ​

void


rm() ​

ts
rm(path, options?): Promise<void>;

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

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:4513

Removes an empty directory

Parameters ​

ParameterType
pathstring

Returns ​

Promise<void>


rmdirSync() ​

ts
rmdirSync(path): void;

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

Parameters ​

ParameterType
pathstring

Returns ​

void


rmSync() ​

ts
rmSync(path, options?): void;

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

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:4502

Parameters ​

ParameterType
pathstring

Returns ​

Promise<Stats>


statSync() ​

ts
statSync(path): Stats;

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

Parameters ​

ParameterType
pathstring

Returns ​

Stats


ts
unlink(path): Promise<void>;

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

Removes a file

Parameters ​

ParameterType
pathstring

Returns ​

Promise<void>


unlinkSync() ​

ts
unlinkSync(path): void;

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

Parameters ​

ParameterType
pathstring

Returns ​

void


writeFile() ​

ts
writeFile(
   path, 
   data, 
   options?
): Promise<void>;

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

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:4492

Parameters ​

ParameterType
pathstring
dataFileData
options?WriteFileOptions

Returns ​

void

The SDK is released under the Apache License 2.0