diff --git a/docs/api/events.md b/docs/api/events.md index 35cb0b7f..1f52680c 100644 --- a/docs/api/events.md +++ b/docs/api/events.md @@ -23,7 +23,7 @@ by the Neutralinojs server based on native state changes. | `extClientDisconnect` | Occurs when an extension disconnects. | `all` | Extension identifer | `extensionReady` | Occurs when an extension is ready to communicate with the app. | `all` | Extension identifier | `spawnedProcess` | Occurs then there is an update in the spawned process. | `all` | [`SpawnedProcess`](os.md#spawnedprocess) with `action` (`stdOut`, `stdErr`, and `exit`) and `data` (STDOUT, STDERR or exit code) -| `openedFile` | Occurs for each read action and whenever stream cursor reaches EOF. | `all` | File stream identifier with `action` (`read` and `end`) and `data` (stream block content) +| `openedFile` | Occurs for each read action and whenever stream cursor reaches EOF. | `all` | File stream identifier with `action` (`data`, `dataBinary`, and `end`) and `data` (stream block content) | `watchFile` | Occurs for each filesystem change events based on watchers. | `all` | File watcher identifier with `action` (`add`, `delete`, `modified`, and `moved`), `dir`, and `filename` ## events.on(eventName, handler) Registers a new event handler.  diff --git a/docs/api/filesystem.md b/docs/api/filesystem.md index 844bb945..f1ed5b84 100644 --- a/docs/api/filesystem.md +++ b/docs/api/filesystem.md @@ -153,12 +153,14 @@ to read and seek an opened file (aka a readable stream). - `id` Number: File stream identifier. - `action` String: An action to take. Accepts only the following values: - `read`: Reads a bytes segment from the file stream. + - `readBinary`: Behaves the same as `read` but uses the binary read mode. - `readAll`: Triggers the `read` action until file stream cursor position reaches [EOF](https://en.wikipedia.org/wiki/End-of-file). + - `readAllBinary`: Behaves the same as `readAll` but uses the binary read mode. - `seek`: Sets the file cursor position. - `close`: Closes and frees file handler resources. - `data` Object (optional): Additional data for the `action`. Send the buffer size in bytes (default: 256 bytes) - if the `action` is `read` or `readAll`. Send the file stream cursor position if the action is `seek`. + if the `action` is `read`, `readBinary`, `readAll`, or `readAllBinary`. Send the file stream cursor position if the action is `seek`. ```js let fileId = await Neutralino.filesystem.openFile('./myFile.txt'); @@ -204,7 +206,8 @@ console.log(info); ``` ## filesystem.createWatcher(path) -Creates a filesystem watcher. Throws `NE_FS_UNLCWAT` for watcher creation failures. +Creates a filesystem watcher. Throws `NE_FS_UNLCWAT` for watcher creation failures. If there is an existing +active watcher for the given path, this function returns the existing watcher identifier. ### Parameters @@ -239,6 +242,24 @@ console.log(`ID: ${watcherId}`); await Neutralino.filesystem.removeWatcher(watcherId); ``` +## filesystem.getWatchers() +Returns information about created file watchers. + +### Return Object (awaited): +An array of `FileWatcher` objects. + +### FileWatcher +- `id` Number: Watcher identifier. +- `path` String: File watcher path. + + +```js +let watchers = await Neutralino.filesystem.getWatchers(); +for(let watcher of watchers) { + console.log(watcher); +} +``` + ## filesystem.removeFile(filename) Removes given file. Throws `NE_FS_FILRMER` for file removal errors. @@ -258,6 +279,10 @@ Reads directory contents. Throws `NE_FS_NOPATHE` if the path doesn't exist. - `path` String: File/directory path. ### Return Object (awaited): +An array of `DirectoryEntry` objects. + +### DirectoryEntry + - `entry` String: file name. - `type` String: The type of the entry (`FILE` or `DIRECTORY`). diff --git a/docs/api/os.md b/docs/api/os.md index c8f8e525..3b048770 100644 --- a/docs/api/os.md +++ b/docs/api/os.md @@ -15,6 +15,7 @@ Executes a command and returns the output. if this is set to `true`. This option makes the process detached from the API function call, so if you need to connect with the newly created process later, consider using `os.spawnProcess`. - `stdIn` String: Standard input as a string. +- `cwd` String: Current working directory. ### Return Object (awaited): - `pid` Number: Process identifier. @@ -29,11 +30,12 @@ console.log(`Your Python version: ${info.stdOut}`); await Neutralino.os.execCommand('npm start', { background: true }); ``` -## os.spawnProcess(command) +## os.spawnProcess(command, cwd) Spawns a process based on a command in background and let developers control it. ### Parameters - `command` String: The command that is to be executed in a new process. +- `cwd` String (optional): Current working directory. ### Return Object (awaited): - `id` Number: A Neutralino-scoped process identifier. This value is used for controlling the