Skip to content

Commit

Permalink
docs: complete the fs module - fs.write, fs.cha, fs.cha_follow
Browse files Browse the repository at this point in the history
  • Loading branch information
sxyazi committed Jan 11, 2024
1 parent 9801621 commit d45a135
Showing 1 changed file with 43 additions and 5 deletions.
48 changes: 43 additions & 5 deletions docs/plugin/utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,51 @@ Returns the name of the current group, which is a string.

## fs

TODO
### `write(url, data)`

```lua
local ok, err = fs.write(url, "hello world")
```

Write data to the specified file:

- `url` - Required, the [Url](./common.md#url) of the file
- `data` - Required, the data to be written, which is a string

Returns `(ok, err)`:

- `ok` - Whether the operation is successful, which is a boolean
- `err` - The error code if the operation is failed, which is a integer if any

### `cha(url)`

```lua
local cha, err = fs.cha(url)
```

Get the [Cha](./common.md#cha) of the specified file, which is faster than [`cha_follow`](#chafollowurl) since it never follows the symbolic link:

- `url` - Required, the [Url](./common.md#url) of the file

Returns `(cha, err)`:

- `cha` - The [Cha](./common.md#cha) of the file, which is a table
- `err` - The error code if the operation is failed, which is a integer if any

### `cha_follow(url)`

```lua
local cha, err = fs.cha_follow(url)
```

Get the [Cha](./common.md#cha) of the specified file, and follow the symbolic link:

- `url` - Required, the [Url](./common.md#url) of the file

Functions:
Returns `(cha, err)`:

- `write(url, data)`
- `metadata(url)`
- `symlink_metadata(url)`
- `cha` - The [Cha](./common.md#cha) of the file, which is a table
- `err` - The error code if the operation is failed, which is a integer if any

## Command

Expand Down

0 comments on commit d45a135

Please sign in to comment.