Home Explore Blog CI



neovim

41th chunk of `runtime/doc/luvref.txt`
5e7994595e5b82973bfeec259ed9aa6bc7d9bedfb6ce7b340000000100000fa3
 `string`
                - `callback`: `callable` (async version) or `nil` (sync
                  version)
                  - `err`: `nil` or `string`
                  - `success`: `boolean` or `nil`

                Equivalent to `rename(2)`.

                Returns (sync version): `boolean` or `fail`

                Returns (async version): `uv_fs_t userdata`

uv.fs_fsync({fd} [, {callback}])                                 *uv.fs_fsync()*

                Parameters:
                - `fd`: `integer`
                - `callback`: `callable` (async version) or `nil` (sync
                  version)
                  - `err`: `nil` or `string`
                  - `success`: `boolean` or `nil`

                Equivalent to `fsync(2)`.

                Returns (sync version): `boolean` or `fail`

                Returns (async version): `uv_fs_t userdata`

uv.fs_fdatasync({fd} [, {callback}])                         *uv.fs_fdatasync()*

                Parameters:
                - `fd`: `integer`
                - `callback`: `callable` (async version) or `nil` (sync
                  version)
                  - `err`: `nil` or `string`
                  - `success`: `boolean` or `nil`

                Equivalent to `fdatasync(2)`.

                Returns (sync version): `boolean` or `fail`

                Returns (async version): `uv_fs_t userdata`

uv.fs_ftruncate({fd}, {offset} [, {callback}])               *uv.fs_ftruncate()*

                Parameters:
                - `fd`: `integer`
                - `offset`: `integer`
                - `callback`: `callable` (async version) or `nil` (sync
                  version)
                  - `err`: `nil` or `string`
                  - `success`: `boolean` or `nil`

                Equivalent to `ftruncate(2)`.

                Returns (sync version): `boolean` or `fail`

                Returns (async version): `uv_fs_t userdata`

                                                              *uv.fs_sendfile()*
uv.fs_sendfile({out_fd}, {in_fd}, {in_offset}, {size} [, {callback}])

                Parameters:
                - `out_fd`: `integer`
                - `in_fd`: `integer`
                - `in_offset`: `integer`
                - `size`: `integer`
                - `callback`: `callable` (async version) or `nil` (sync
                  version)
                  - `err`: `nil` or `string`
                  - `bytes`: `integer` or `nil`

                Limited equivalent to `sendfile(2)`. Returns the number of
                bytes written.

                Returns (sync version): `integer` or `fail`

                Returns (async version): `uv_fs_t userdata`

uv.fs_access({path}, {mode} [, {callback}])                     *uv.fs_access()*

                Parameters:
                - `path`: `string`
                - `mode`: `integer` `string` (a combination of the `'r'`,
                  `'w'` and `'x'` characters denoting the symbolic mode as per
                  `chmod(1)`)
                - `callback`: `callable` (async version) or `nil` (sync
                  version)
                  - `err`: `nil` or `string`
                  - `permission`: `boolean` or `nil`

                Equivalent to `access(2)` on Unix. Windows uses
                `GetFileAttributesW()`. Access `mode` can be an integer or a
                string containing `"R"` or `"W"` or `"X"`. Returns `true` or
                `false` indicating access permission.

                Returns (sync version): `boolean` or `fail`

                Returns (async version): `uv_fs_t userdata`

uv.fs_chmod({path}, {mode} [, {callback}])                       *uv.fs_chmod()*

                Parameters:
                - `path`: `string`
                - `mode`: `integer` (octal representation of `chmod(1)` mode,
                  e.g. `tonumber('644', 8)`)
                - `callback`: `callable` (async version) or `nil` (sync
                  version)
                  - `err`: `nil`

Title: File System Operations: Truncate, Sendfile, Access, and Chmod
Summary
This section describes the `uv.fs_ftruncate()`, `uv.fs_sendfile()`, `uv.fs_access()`, and `uv.fs_chmod()` functions in libuv. `uv.fs_ftruncate()` truncates a file to a specified length. `uv.fs_sendfile()` copies data between file descriptors. `uv.fs_access()` checks file access permissions, accepting a path and a mode (read, write, execute). `uv.fs_chmod()` changes file permissions. Each function details its parameters, return values (including synchronous and asynchronous versions), and equivalents to standard C library functions like `ftruncate(2)`, `sendfile(2)`, `access(2)`, and `chmod(1)`.