From d45a1352039443b170d3665d7d0a23dd8fe0d6d2 Mon Sep 17 00:00:00 2001 From: sxyazi Date: Thu, 11 Jan 2024 16:43:13 +0800 Subject: [PATCH] docs: complete the fs module - fs.write, fs.cha, fs.cha_follow --- docs/plugin/utils.md | 48 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/docs/plugin/utils.md b/docs/plugin/utils.md index 63bbf37a..1cd62aa0 100644 --- a/docs/plugin/utils.md +++ b/docs/plugin/utils.md @@ -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