Skip to content

Commit 7329537

Browse files
bnoordhuisMylesBorins
authored andcommitted
doc: document fs.realpath.native()
Mea culpa, somehow I managed to drop the documentation commit while merging the pull request. This should have been included in commit 74023c0 ("fs: expose realpath(3) bindings") from this month. PR-URL: #17059 Refs: #15776 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
1 parent cf7e15c commit 7329537

File tree

1 file changed

+75
-4
lines changed

1 file changed

+75
-4
lines changed

doc/api/fs.md

+75-4
Original file line numberDiff line numberDiff line change
@@ -2028,8 +2028,21 @@ changes:
20282028
* `err` {Error}
20292029
* `resolvedPath` {string|Buffer}
20302030

2031-
Asynchronous realpath(3). The `callback` gets two arguments `(err,
2032-
resolvedPath)`. May use `process.cwd` to resolve relative paths.
2031+
Asynchronously computes the canonical pathname by resolving `.`, `..` and
2032+
symbolic links.
2033+
2034+
Note that "canonical" does not mean "unique": hard links and bind mounts can
2035+
expose a file system entity through many pathnames.
2036+
2037+
This function behaves like realpath(3), with some exceptions:
2038+
2039+
1. No case conversion is performed on case-insensitive file systems.
2040+
2041+
2. The maximum number of symbolic links is platform-independent and generally
2042+
(much) higher than what the native realpath(3) implementation supports.
2043+
2044+
The `callback` gets two arguments `(err, resolvedPath)`. May use `process.cwd`
2045+
to resolve relative paths.
20332046

20342047
Only paths that can be converted to UTF8 strings are supported.
20352048

@@ -2041,6 +2054,33 @@ the path returned will be passed as a `Buffer` object.
20412054
*Note*: If `path` resolves to a socket or a pipe, the function will return a
20422055
system dependent name for that object.
20432056

2057+
## fs.realpath.native(path[, options], callback)
2058+
<!-- YAML
2059+
added: v9.2.0
2060+
-->
2061+
2062+
* `path` {string|Buffer|URL}
2063+
* `options` {string|Object}
2064+
* `encoding` {string} **Default:** `'utf8'`
2065+
* `callback` {Function}
2066+
* `err` {Error}
2067+
* `resolvedPath` {string|Buffer}
2068+
2069+
Asynchronous realpath(3).
2070+
2071+
The `callback` gets two arguments `(err, resolvedPath)`.
2072+
2073+
Only paths that can be converted to UTF8 strings are supported.
2074+
2075+
The optional `options` argument can be a string specifying an encoding, or an
2076+
object with an `encoding` property specifying the character encoding to use for
2077+
the path passed to the callback. If the `encoding` is set to `'buffer'`,
2078+
the path returned will be passed as a `Buffer` object.
2079+
2080+
*Note*: On Linux, when Node.js is linked against musl libc, the procfs file
2081+
system must be mounted on `/proc` in order for this function to work. Glibc
2082+
does not have this restriction.
2083+
20442084
## fs.realpathSync(path[, options])
20452085
<!-- YAML
20462086
added: v0.1.31
@@ -2065,9 +2105,18 @@ changes:
20652105
* `options` {string|Object}
20662106
* `encoding` {string} **Default:** `'utf8'`
20672107

2068-
Synchronous realpath(3). Returns the resolved path.
2108+
Synchronously computes the canonical pathname by resolving `.`, `..` and
2109+
symbolic links.
20692110

2070-
Only paths that can be converted to UTF8 strings are supported.
2111+
Note that "canonical" does not mean "unique": hard links and bind mounts can
2112+
expose a file system entity through many pathnames.
2113+
2114+
This function behaves like realpath(3), with some exceptions:
2115+
2116+
1. No case conversion is performed on case-insensitive file systems.
2117+
2118+
2. The maximum number of symbolic links is platform-independent and generally
2119+
(much) higher than what the native realpath(3) implementation supports.
20712120

20722121
The optional `options` argument can be a string specifying an encoding, or an
20732122
object with an `encoding` property specifying the character encoding to use for
@@ -2077,6 +2126,28 @@ will be passed as a `Buffer` object.
20772126
*Note*: If `path` resolves to a socket or a pipe, the function will return a
20782127
system dependent name for that object.
20792128

2129+
## fs.realpathSync.native(path[, options])
2130+
<!-- YAML
2131+
added: v9.2.0
2132+
-->
2133+
2134+
* `path` {string|Buffer|URL}
2135+
* `options` {string|Object}
2136+
* `encoding` {string} **Default:** `'utf8'`
2137+
2138+
Synchronous realpath(3).
2139+
2140+
Only paths that can be converted to UTF8 strings are supported.
2141+
2142+
The optional `options` argument can be a string specifying an encoding, or an
2143+
object with an `encoding` property specifying the character encoding to use for
2144+
the path passed to the callback. If the `encoding` is set to `'buffer'`,
2145+
the path returned will be passed as a `Buffer` object.
2146+
2147+
*Note*: On Linux, when Node.js is linked against musl libc, the procfs file
2148+
system must be mounted on `/proc` in order for this function to work. Glibc
2149+
does not have this restriction.
2150+
20802151
## fs.rename(oldPath, newPath, callback)
20812152
<!-- YAML
20822153
added: v0.0.2

0 commit comments

Comments
 (0)