Skip to content

Commit

Permalink
Update docs for the latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
shalithasuranga committed Sep 20, 2023
1 parent 5eb14ef commit 09aa4b4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/api/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. 
Expand Down
29 changes: 27 additions & 2 deletions docs/api/filesystem.md
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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.

Expand All @@ -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`).

Expand Down
4 changes: 3 additions & 1 deletion docs/api/os.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down

0 comments on commit 09aa4b4

Please sign in to comment.