doc: refactor mode constants parts in fs.md

1. removed extra mode constants doc.
2. creates bookmark to the common File Access Contants block.

PR-URL: https://github.com/nodejs/node/pull/20558
Fixes: https://github.com/nodejs/node/issues/20049
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
This commit is contained in:
Shobhit Chittora 2018-05-06 13:05:21 +05:30 committed by Vse Mozhet Byt
parent ac89450326
commit a76dfd24ec

View File

@ -746,17 +746,9 @@ changes:
Tests a user's permissions for the file or directory specified by `path`. Tests a user's permissions for the file or directory specified by `path`.
The `mode` argument is an optional integer that specifies the accessibility The `mode` argument is an optional integer that specifies the accessibility
checks to be performed. The following constants define the possible values of checks to be performed. Check [File Access Constants][] for possible values
`mode`. It is possible to create a mask consisting of the bitwise OR of two or of `mode`. It is possible to create a mask consisting of the bitwise OR of
more values (e.g. `fs.constants.W_OK | fs.constants.R_OK`). two or more values (e.g. `fs.constants.W_OK | fs.constants.R_OK`).
* `fs.constants.F_OK` - `path` is visible to the calling process. This is useful
for determining if a file exists, but says nothing about `rwx` permissions.
Default if no `mode` is specified.
* `fs.constants.R_OK` - `path` can be read by the calling process.
* `fs.constants.W_OK` - `path` can be written by the calling process.
* `fs.constants.X_OK` - `path` can be executed by the calling process. This has
no effect on Windows (will behave like `fs.constants.F_OK`).
The final argument, `callback`, is a callback function that is invoked with The final argument, `callback`, is a callback function that is invoked with
a possible error argument. If any of the accessibility checks fail, the error a possible error argument. If any of the accessibility checks fail, the error
@ -889,19 +881,12 @@ changes:
* `path` {string|Buffer|URL} * `path` {string|Buffer|URL}
* `mode` {integer} **Default:** `fs.constants.F_OK` * `mode` {integer} **Default:** `fs.constants.F_OK`
Synchronously tests a user's permissions for the file or directory specified by Synchronously tests a user's permissions for the file or directory specified
`path`. The `mode` argument is an optional integer that specifies the by `path`. The `mode` argument is an optional integer that specifies the
accessibility checks to be performed. The following constants define the accessibility checks to be performed. Check [File Access Constants][] for
possible values of `mode`. It is possible to create a mask consisting of the possible values of `mode`. It is possible to create a mask consisting of
bitwise OR of two or more values (e.g. `fs.constants.W_OK | fs.constants.R_OK`). the bitwise OR of two or more values
(e.g. `fs.constants.W_OK | fs.constants.R_OK`).
* `fs.constants.F_OK` - `path` is visible to the calling process. This is useful
for determining if a file exists, but says nothing about `rwx` permissions.
Default if no `mode` is specified.
* `fs.constants.R_OK` - `path` can be read by the calling process.
* `fs.constants.W_OK` - `path` can be written by the calling process.
* `fs.constants.X_OK` - `path` can be executed by the calling process. This has
no effect on Windows (will behave like `fs.constants.F_OK`).
If any of the accessibility checks fail, an `Error` will be thrown. Otherwise, If any of the accessibility checks fail, an `Error` will be thrown. Otherwise,
the method will return `undefined`. the method will return `undefined`.
@ -3679,17 +3664,9 @@ added: v10.0.0
Tests a user's permissions for the file or directory specified by `path`. Tests a user's permissions for the file or directory specified by `path`.
The `mode` argument is an optional integer that specifies the accessibility The `mode` argument is an optional integer that specifies the accessibility
checks to be performed. The following constants define the possible values of checks to be performed. Check [File Access Constants][] for possible values
`mode`. It is possible to create a mask consisting of the bitwise OR of two or of `mode`. It is possible to create a mask consisting of the bitwise OR of
more values (e.g. `fs.constants.W_OK | fs.constants.R_OK`). two or more values (e.g. `fs.constants.W_OK | fs.constants.R_OK`).
* `fs.constants.F_OK` - `path` is visible to the calling process. This is useful
for determining if a file exists, but says nothing about `rwx` permissions.
Default if no `mode` is specified.
* `fs.constants.R_OK` - `path` can be read by the calling process.
* `fs.constants.W_OK` - `path` can be written by the calling process.
* `fs.constants.X_OK` - `path` can be executed by the calling process. This has
no effect on Windows (will behave like `fs.constants.F_OK`).
If the accessibility check is successful, the `Promise` is resolved with no If the accessibility check is successful, the `Promise` is resolved with no
value. If any of the accessibility checks fail, the `Promise` is rejected value. If any of the accessibility checks fail, the `Promise` is rejected
@ -4329,7 +4306,9 @@ The following constants are meant for use with [`fs.access()`][].
</tr> </tr>
<tr> <tr>
<td><code>F_OK</code></td> <td><code>F_OK</code></td>
<td>Flag indicating that the file is visible to the calling process.</td> <td>Flag indicating that the file is visible to the calling process.
This is useful for determining if a file exists, but says nothing
about <code>rwx</code> permissions. Default if no mode is specified.</td>
</tr> </tr>
<tr> <tr>
<td><code>R_OK</code></td> <td><code>R_OK</code></td>
@ -4343,7 +4322,8 @@ The following constants are meant for use with [`fs.access()`][].
<tr> <tr>
<td><code>X_OK</code></td> <td><code>X_OK</code></td>
<td>Flag indicating that the file can be executed by the calling <td>Flag indicating that the file can be executed by the calling
process.</td> process. This has no effect on Windows
(will behave like <code>fs.constants.F_OK</code>).</td>
</tr> </tr>
</table> </table>
@ -4706,3 +4686,4 @@ the file contents.
[Naming Files, Paths, and Namespaces]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx [Naming Files, Paths, and Namespaces]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
[MSDN-Using-Streams]: https://msdn.microsoft.com/en-us/library/windows/desktop/bb540537.aspx [MSDN-Using-Streams]: https://msdn.microsoft.com/en-us/library/windows/desktop/bb540537.aspx
[support of file system `flags`]: #fs_file_system_flags [support of file system `flags`]: #fs_file_system_flags
[File Access Constants]: #fs_file_access_constants