Skip to content

Fs

fs : object

Basic filesystem access utility functions, wrapping Node.JS and/or NW.JS code.

Kind: global namespace

fs.openFileSaveDialog(suggestedFilename, fileExtensions) ⇒ Promise.<(string|null)>

Open a file save as dialog prompting the user to save a file. Opens to the user's Documents folder, with sane fallbacks if it cannot be located.

Kind: static method of fs
Returns: Promise.<(string|null)> - The full file path the user selected, or null if they cancelled.

Param Type Description
suggestedFilename string The filename string to pre-fill in the dialog.
fileExtensions string The file type filter to show. Examples: ".csv", ".csv,.html"

fs.openFileBrowseDialog(chooseFolder, accept, dialogTitle) ⇒ string | null

Open a file browse/file open dialog prompting the user to select a file or folder. Opens to the user's Documents folder, with sane fallbacks if it cannot be located.

Kind: static method of fs
Returns: string | null - The selected file/folder path, or null if cancelled.

Param Type Default Description
chooseFolder boolean false Set to true to choose a folder instead of a file.
accept string File filter. ".csv,.html", "image/*", etc.
dialogTitle string | null null Title of the file open dialog.

fs.writeFile(filename, data, encoding, flag) ⇒ Promise

Write a file to disk.

Kind: static method of fs

Param Type Default Description
filename string The path and filename to write to.
data string | Buffer | ArrayBuffer | Uint8Array Data to write to the file.
encoding string | null "utf8" Text encoding. Set to empty if not passing string data.
flag string | null "w+" Filesystem flag.

fs.readFile(filename, encoding, flag) ⇒ Promise.<(string|Buffer)>

Read a file from disk and return its contents.

Kind: static method of fs

Param Type Default Description
filename string The path and filename to read from.
encoding string "utf8" File encoding. Set to null or empty string when reading binary data.
flag string "r+" Filesystem flag.

fs.fileExists(filename) ⇒ boolean

Check if a file exists.

Kind: static method of fs

Param Type Description
filename string Path and filename to check.