Lines Matching full:path

16           "desc": "<p>Promise-based operations return a promise that is fulfilled when the\nasynchronous operation is complete.</p>\n<pre><code class=\"language-mjs\">import { unlink } from 'node:fs/promises';\n\ntry {\n  await unlink('/tmp/hello');\n  console.log('successfully deleted /tmp/hello');\n} catch (error) {\n  console.error('there was an error:', error.message);\n}\n</code></pre>\n<pre><code class=\"language-cjs\">const { unlink } = require('node:fs/promises');\n\n(async function(path) {\n  try {\n    await unlink(path);\n    console.log(`successfully deleted ${path}`);\n  } catch (error) {\n    console.error('there was an error:', error.message);\n  }\n})('/tmp/hello');\n</code></pre>",
1202 "textRaw": "`fsPromises.access(path[, mode])`",
1221 "textRaw": "`path` {string|Buffer|URL}",
1222 "name": "path",
1234 "desc": "<p>Tests a user's permissions for the file or directory specified by <code>path</code>.\nThe <code>mode</code> argument is an optional integer that specifies the accessibility\nchecks to be performed. <code>mode</code> should be either the value <code>fs.constants.F_OK</code>\nor a mask consisting of the bitwise OR of any of <code>fs.constants.R_OK</code>,\n<code>fs.constants.W_OK</code>, and <code>fs.constants.X_OK</code> (e.g.\n<code>fs.constants.W_OK | fs.constants.R_OK</code>). Check <a href=\"#file-access-constants\">File access constants</a> for\npossible values of <code>mode</code>.</p>\n<p>If the accessibility check is successful, the promise is resolved with no\nvalue. If any of the accessibility checks fail, the promise is rejected\nwith an <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error\" class=\"type\">&lt;Error&gt;</a> object. The following example checks if the file\n<code>/etc/passwd</code> can be read and written by the current process.</p>\n<pre><code class=\"language-mjs\">import { access, constants } from 'node:fs/promises';\n\ntry {\n await access('/etc/passwd', constants.R_OK | constants.W_OK);\n console.log('can access');\n} catch {\n console.error('cannot access');\n}\n</code></pre>\n<p>Using <code>fsPromises.access()</code> to check for the accessibility of a file before\ncalling <code>fsPromises.open()</code> is not recommended. Doing so introduces a race\ncondition, since other processes may change the file's state between the two\ncalls. Instead, user code should open/read/write the file directly and handle\nthe error raised if the file is not accessible.</p>"
1237 "textRaw": "`fsPromises.appendFile(path, data[, options])`",
1256 "textRaw": "`path` {string|Buffer|URL|FileHandle} filename or {FileHandle}",
1257 "name": "path",
1295 "desc": "<p>Asynchronously append data to a file, creating the file if it does not yet\nexist. <code>data</code> can be a string or a <a href=\"buffer.html#class-buffer\" class=\"type\">&lt;Buffer&gt;</a>.</p>\n<p>If <code>options</code> is a string, then it specifies the <code>encoding</code>.</p>\n<p>The <code>mode</code> option only affects the newly created file. See <a href=\"#fsopenpath-flags-mode-callback\"><code>fs.open()</code></a>\nfor more details.</p>\n<p>The <code>path</code> may be specified as a <a href=\"fs.html#class-filehandle\" class=\"type\">&lt;FileHandle&gt;</a> that has been opened\nfor appending (using <code>fsPromises.open()</code>).</p>"
1298 "textRaw": "`fsPromises.chmod(path, mode)`",
1317 "textRaw": "`path` {string|Buffer|URL}",
1318 "name": "path",
1332 "textRaw": "`fsPromises.chown(path, uid, gid)`",
1351 "textRaw": "`path` {string|Buffer|URL}",
1352 "name": "path",
1453 "description": "Accepts an additional `verbatimSymlinks` option to specify whether to perform path resolution for symlinks."
1469 "textRaw": "`src` {string|URL} source path to copy.",
1472 "desc": "source path to copy."
1475 "textRaw": "`dest` {string|URL} destination path to copy to.",
1478 "desc": "destination path to copy to."
1507 "textRaw": "`src` {string} source path to copy.",
1510 "desc": "source path to copy."
1513 "textRaw": "`dest` {string} destination path to copy to.",
1516 "desc": "destination path to copy to."
1554 "textRaw": "`verbatimSymlinks` {boolean} When `true`, path resolution for symlinks will be skipped. **Default:** `false`",
1558 "desc": "When `true`, path resolution for symlinks will be skipped."
1568 "textRaw": "`fsPromises.lchmod(path, mode)`",
1587 "textRaw": "`path` {string|Buffer|URL}",
1588 "name": "path",
1602 "textRaw": "`fsPromises.lchown(path, uid, gid)`",
1627 "textRaw": "`path` {string|Buffer|URL}",
1628 "name": "path",
1647 "textRaw": "`fsPromises.lutimes(path, atime, mtime)`",
1667 "textRaw": "`path` {string|Buffer|URL}",
1668 "name": "path",
1684 "desc": "<p>Changes the access and modification times of a file in the same way as\n<a href=\"#fspromisesutimespath-atime-mtime\"><code>fsPromises.utimes()</code></a>, with the difference that if the path refers to a\nsymbolic link, then the link is not dereferenced: instead, the timestamps of\nthe symbolic link itself are changed.</p>"
1721 "textRaw": "`fsPromises.lstat(path[, options])`",
1739 "textRaw": "Returns: {Promise} Fulfills with the {fs.Stats} object for the given symbolic link `path`.",
1742 "desc": "Fulfills with the {fs.Stats} object for the given symbolic link `path`."
1746 "textRaw": "`path` {string|Buffer|URL}",
1747 "name": "path",
1767 "desc": "<p>Equivalent to <a href=\"#fspromisesstatpath-options\"><code>fsPromises.stat()</code></a> unless <code>path</code> refers to a symbolic link,\nin which case the link itself is stat-ed, not the file that it refers to.\nRefer to the POSIX <a href=\"http://man7.org/linux/man-pages/man2/lstat.2.html\"><code>lstat(2)</code></a> document for more detail.</p>"
1770 "textRaw": "`fsPromises.mkdir(path[, options])`",
1782 "textRaw": "Returns: {Promise} Upon success, fulfills with `undefined` if `recursive` is `false`, or the first directory path created if `recursive` is `true`.",
1785 "desc": "Upon success, fulfills with `undefined` if `recursive` is `false`, or the first directory path created if `recursive` is `true`."
1789 "textRaw": "`path` {string|Buffer|URL}",
1790 "name": "path",
1816 "desc": "<p>Asynchronously creates a directory.</p>\n<p>The optional <code>options</code> argument can be an integer specifying <code>mode</code> (permission\nand sticky bits), or an object with a <code>mode</code> property and a <code>recursive</code>\nproperty indicating whether parent directories should be created. Calling\n<code>fsPromises.mkdir()</code> when <code>path</code> is a directory that exists results in a\nrejection only when <code>recursive</code> is false.</p>\n<pre><code class=\"language-mjs\">import { mkdir } from 'node:fs/promises';\n\ntry {\n const projectFolder = new URL('./test/project/', import.meta.url);\n const createDir = await mkdir(projectFolder, { recursive: true });\n\n console.log(`created ${createDir}`);\n} catch (err) {\n console.error(err.message);\n}\n</code></pre>\n<pre><code class=\"language-cjs\">const { mkdir } = require('node:fs/promises');\nconst { join } = require('node:path');\n\nasync function makeDirectory() {\n const projectFolder = join(__dirname, 'test', 'project');\n const dirCreation = await mkdir(projectFolder, { recursive: true });\n\n console.log(dirCreation);\n return dirCreation;\n}\n\nmakeDirectory().catch(console.error);\n</code></pre>"
1845 "textRaw": "Returns: {Promise} Fulfills with a string containing the file system path of the newly created temporary directory.",
1848 "desc": "Fulfills with a string containing the file system path of the newly created temporary directory."
1872 "desc": "<p>Creates a unique temporary directory. A unique directory name is generated by\nappending six random characters to the end of the provided <code>prefix</code>. Due to\nplatform inconsistencies, avoid trailing <code>X</code> characters in <code>prefix</code>. Some\nplatforms, notably the BSDs, can return more than six random characters, and\nreplace trailing <code>X</code> characters in <code>prefix</code> with random characters.</p>\n<p>The optional <code>options</code> argument can be a string specifying an encoding, or an\nobject with an <code>encoding</code> property specifying the character encoding to use.</p>\n<pre><code class=\"language-mjs\">import { mkdtemp } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { tmpdir } from 'node:os';\n\ntry {\n await mkdtemp(join(tmpdir(), 'foo-'));\n} catch (err) {\n console.error(err);\n}\n</code></pre>\n<p>The <code>fsPromises.mkdtemp()</code> method will append the six randomly selected\ncharacters directly to the <code>prefix</code> string. For instance, given a directory\n<code>/tmp</code>, if the intention is to create a temporary directory <em>within</em> <code>/tmp</code>, the\n<code>prefix</code> must end with a trailing platform-specific path separator\n(<code>require('node:path').sep</code>).</p>"
1875 "textRaw": "`fsPromises.open(path, flags[, mode])`",
1900 "textRaw": "`path` {string|Buffer|URL}",
1901 "name": "path",
1924 "textRaw": "`fsPromises.opendir(path[, options])`",
1957 "textRaw": "`path` {string|Buffer|URL}",
1958 "name": "path",
1991 "desc": "<p>Asynchronously open a directory for iterative scanning. See the POSIX\n<a href=\"http://man7.org/linux/man-pages/man3/opendir.3.html\"><code>opendir(3)</code></a> documentation for more detail.</p>\n<p>Creates an <a href=\"fs.html#class-fsdir\" class=\"type\">&lt;fs.Dir&gt;</a>, which contains all further functions for reading from\nand cleaning up the directory.</p>\n<p>The <code>encoding</code> option sets the encoding for the <code>path</code> while opening the\ndirectory and subsequent read operations.</p>\n<p>Example using async iteration:</p>\n<pre><code class=\"language-mjs\">import { opendir } from 'node:fs/promises';\n\ntry {\n const dir = await opendir('./');\n for await (const dirent of dir)\n console.log(dirent.name);\n} catch (err) {\n console.error(err);\n}\n</code></pre>\n<p>When using the async iterator, the <a href=\"fs.html#class-fsdir\" class=\"type\">&lt;fs.Dir&gt;</a> object will be automatically\nclosed after the iterator exits.</p>"
1994 "textRaw": "`fsPromises.readdir(path[, options])`",
2024 "textRaw": "`path` {string|Buffer|URL}",
2025 "name": "path",
2056 "desc": "<p>Reads the contents of a directory.</p>\n<p>The optional <code>options</code> argument can be a string specifying an encoding, or an\nobject with an <code>encoding</code> property specifying the character encoding to use for\nthe filenames. If the <code>encoding</code> is set to <code>'buffer'</code>, the filenames returned\nwill be passed as <a href=\"buffer.html#class-buffer\" class=\"type\">&lt;Buffer&gt;</a> objects.</p>\n<p>If <code>options.withFileTypes</code> is set to <code>true</code>, the resolved array will contain\n<a href=\"fs.html#class-fsdirent\" class=\"type\">&lt;fs.Dirent&gt;</a> objects.</p>\n<pre><code class=\"language-mjs\">import { readdir } from 'node:fs/promises';\n\ntry {\n const files = await readdir(path);\n for (const file of files)\n console.log(file);\n} catch (err) {\n console.error(err);\n}\n</code></pre>"
2059 "textRaw": "`fsPromises.readFile(path[, options])`",
2087 "textRaw": "`path` {string|Buffer|URL|FileHandle} filename or `FileHandle`",
2088 "name": "path",
2121 "desc": "<p>Asynchronously reads the entire contents of a file.</p>\n<p>If no encoding is specified (using <code>options.encoding</code>), the data is returned\nas a <a href=\"buffer.html#class-buffer\" class=\"type\">&lt;Buffer&gt;</a> object. Otherwise, the data will be a string.</p>\n<p>If <code>options</code> is a string, then it specifies the encoding.</p>\n<p>When the <code>path</code> is a directory, the behavior of <code>fsPromises.readFile()</code> is\nplatform-specific. On macOS, Linux, and Windows, the promise will be rejected\nwith an error. On FreeBSD, a representation of the directory's contents will be\nreturned.</p>\n<p>An example of reading a <code>package.json</code> file located in the same directory of the\nrunning code:</p>\n<pre><code class=\"language-mjs\">import { readFile } from 'node:fs/promises';\ntry {\n const filePath = new URL('./package.json', import.meta.url);\n const contents = await readFile(filePath, { encoding: 'utf8' });\n console.log(contents);\n} catch (err) {\n console.error(err.message);\n}\n</code></pre>\n<pre><code class=\"language-cjs\">const { readFile } = require('node:fs/promises');\nconst { resolve } = require('node:path');\nasync function logFile() {\n try {\n const filePath = resolve('./package.json');\n const contents = await readFile(filePath, { encoding: 'utf8' });\n console.log(contents);\n } catch (err) {\n console.error(err.message);\n }\n}\nlogFile();\n</code></pre>\n<p>It is possible to abort an ongoing <code>readFile</code> using an <a href=\"globals.html#class-abortsignal\" class=\"type\">&lt;AbortSignal&gt;</a>. If a\nrequest is aborted the promise returned is rejected with an <code>AbortError</code>:</p>\n<pre><code class=\"language-mjs\">import { readFile } from 'node:fs/promises';\n\ntry {\n const controller = new AbortController();\n const { signal } = controller;\n const promise = readFile(fileName, { signal });\n\n // Abort the request before the promise settles.\n controller.abort();\n\n await promise;\n} catch (err) {\n // When a request is aborted - err is an AbortError\n console.error(err);\n}\n</code></pre>\n<p>Aborting an ongoing request does not abort individual operating\nsystem requests but rather the internal buffering <code>fs.readFile</code> performs.</p>\n<p>Any specified <a href=\"fs.html#class-filehandle\" class=\"type\">&lt;FileHandle&gt;</a> has to support reading.</p>"
2124 "textRaw": "`fsPromises.readlink(path[, options])`",
2143 "textRaw": "`path` {string|Buffer|URL}",
2144 "name": "path",
2163 "desc": "<p>Reads the contents of the symbolic link referred to by <code>path</code>. See the POSIX\n<a href=\"http://man7.org/linux/man-pages/man2/readlink.2.html\"><code>readlink(2)</code></a> documentation for more detail. The promise is resolved with the\n<code>linkString</code> upon success.</p>\n<p>The optional <code>options</code> argument can be a string specifying an encoding, or an\nobject with an <code>encoding</code> property specifying the character encoding to use for\nthe link path returned. If the <code>encoding</code> is set to <code>'buffer'</code>, the link path\nreturned will be passed as a <a href=\"buffer.html#class-buffer\" class=\"type\">&lt;Buffer&gt;</a> object.</p>"
2166 "textRaw": "`fsPromises.realpath(path[, options])`",
2178 "textRaw": "Returns: {Promise} Fulfills with the resolved path upon success.",
2181 "desc": "Fulfills with the resolved path upon success."
2185 "textRaw": "`path` {string|Buffer|URL}",
2186 "name": "path",
2205 "desc": "<p>Determines the actual location of <code>path</code> using the same semantics as the\n<code>fs.realpath.native()</code> function.</p>\n<p>Only paths that can be converted to UTF8 strings are supported.</p>\n<p>The optional <code>options</code> argument can be a string specifying an encoding, or an\nobject with an <code>encoding</code> property specifying the character encoding to use for\nthe path. If the <code>encoding</code> is set to <code>'buffer'</code>, the path returned will be\npassed as a <a href=\"buffer.html#class-buffer\" class=\"type\">&lt;Buffer&gt;</a> object.</p>\n<p>On Linux, when Node.js is linked against musl libc, the procfs file system must\nbe mounted on <code>/proc</code> in order for this function to work. Glibc does not have\nthis restriction.</p>"
2242 "textRaw": "`fsPromises.rmdir(path[, options])`",
2253 "description": "Using `fsPromises.rmdir(path, { recursive: true })` on a `path` that is a file is no longer permitted and results in an `ENOENT` error on Windows and an `ENOTDIR` error on POSIX."
2258 "description": "Using `fsPromises.rmdir(path, { recursive: true })` on a `path` that does not exist is no longer permitted and results in a `ENOENT` error."
2295 "textRaw": "`path` {string|Buffer|URL}",
2296 "name": "path",
2330 "desc": "<p>Removes the directory identified by <code>path</code>.</p>\n<p>Using <code>fsPromises.rmdir()</code> on a file (not a directory) results in the\npromise being rejected with an <code>ENOENT</code> error on Windows and an <code>ENOTDIR</code>\nerror on POSIX.</p>\n<p>To get a behavior similar to the <code>rm -rf</code> Unix command, use\n<a href=\"#fspromisesrmpath-options\"><code>fsPromises.rm()</code></a> with options <code>{ recursive: true, force: true }</code>.</p>"
2333 "textRaw": "`fsPromises.rm(path[, options])`",
2352 "textRaw": "`path` {string|Buffer|URL}",
2353 "name": "path",
2362 "textRaw": "`force` {boolean} When `true`, exceptions will be ignored if `path` does not exist. **Default:** `false`.",
2366 "desc": "When `true`, exceptions will be ignored if `path` does not exist."
2397 "textRaw": "`fsPromises.stat(path[, options])`",
2415 "textRaw": "Returns: {Promise} Fulfills with the {fs.Stats} object for the given `path`.",
2418 "desc": "Fulfills with the {fs.Stats} object for the given `path`."
2422 "textRaw": "`path` {string|Buffer|URL}",
2423 "name": "path",
2445 "textRaw": "`fsPromises.statfs(path[, options])`",
2457 "textRaw": "Returns: {Promise} Fulfills with the {fs.StatFs} object for the given `path`.",
2460 "desc": "Fulfills with the {fs.StatFs} object for the given `path`."
2464 "textRaw": "`path` {string|Buffer|URL}",
2465 "name": "path",
2487 "textRaw": "`fsPromises.symlink(target, path[, type])`",
2511 "textRaw": "`path` {string|Buffer|URL}",
2512 "name": "path",
2524 "desc": "<p>Creates a symbolic link.</p>\n<p>The <code>type</code> argument is only used on Windows platforms and can be one of <code>'dir'</code>,\n<code>'file'</code>, or <code>'junction'</code>. Windows junction points require the destination path\nto be absolute. When using <code>'junction'</code>, the <code>target</code> argument will\nautomatically be normalized to absolute path. Junction points on NTFS volumes\ncan only point to directories.</p>"
2527 "textRaw": "`fsPromises.truncate(path[, len])`",
2546 "textRaw": "`path` {string|Buffer|URL}",
2547 "name": "path",
2559 "desc": "<p>Truncates (shortens or extends the length) of the content at <code>path</code> to <code>len</code>\nbytes.</p>"
2562 "textRaw": "`fsPromises.unlink(path)`",
2581 "textRaw": "`path` {string|Buffer|URL}",
2582 "name": "path",
2588 "desc": "<p>If <code>path</code> refers to a symbolic link, then the link is removed without affecting\nthe file or directory to which that link refers. If the <code>path</code> refers to a file\npath that is not a symbolic link, the file is deleted. See the POSIX <a href=\"http://man7.org/linux/man-pages/man2/unlink.2.html\"><code>unlink(2)</code></a>\ndocumentation for more detail.</p>"
2591 "textRaw": "`fsPromises.utimes(path, atime, mtime)`",
2610 "textRaw": "`path` {string|Buffer|URL}",
2611 "name": "path",
2627 "desc": "<p>Change the file system timestamps of the object referenced by <code>path</code>.</p>\n<p>The <code>atime</code> and <code>mtime</code> arguments follow these rules:</p>\n<ul>\n<li>Values can be either numbers representing Unix epoch time, <code>Date</code>s, or a\nnumeric string like <code>'123456789.0'</code>.</li>\n<li>If the value can not be converted to a number, or is <code>NaN</code>, <code>Infinity</code>, or\n<code>-Infinity</code>, an <code>Error</code> will be thrown.</li>\n</ul>"
2821 "textRaw": "`fs.access(path[, mode], callback)`",
2837 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
2850 "textRaw": "`path` {string|Buffer|URL}",
2851 "name": "path",
2875 "desc": "<p>Tests a user's permissions for the file or directory specified by <code>path</code>.\nThe <code>mode</code> argument is an optional integer that specifies the accessibility\nchecks to be performed. <code>mode</code> should be either the value <code>fs.constants.F_OK</code>\nor a mask consisting of the bitwise OR of any of <code>fs.constants.R_OK</code>,\n<code>fs.constants.W_OK</code>, and <code>fs.constants.X_OK</code> (e.g.\n<code>fs.constants.W_OK | fs.constants.R_OK</code>). Check <a href=\"#file-access-constants\">File access constants</a> for\npossible values of <code>mode</code>.</p>\n<p>The final argument, <code>callback</code>, is a callback function that is invoked with\na possible error argument. If any of the accessibility checks fail, the error\nargument will be an <code>Error</code> object. The following examples check if\n<code>package.json</code> exists, and if it is readable or writable.</p>\n<pre><code class=\"language-mjs\">import { access, constants } from 'node:fs';\n\nconst file = 'package.json';\n\n// Check if the file exists in the current directory.\naccess(file, constants.F_OK, (err) => {\n console.log(`${file} ${err ? 'does not exist' : 'exists'}`);\n});\n\n// Check if the file is readable.\naccess(file, constants.R_OK, (err) => {\n console.log(`${file} ${err ? 'is not readable' : 'is readable'}`);\n});\n\n// Check if the file is writable.\naccess(file, constants.W_OK, (err) => {\n console.log(`${file} ${err ? 'is not writable' : 'is writable'}`);\n});\n\n// Check if the file is readable and writable.\naccess(file, constants.R_OK | constants.W_OK, (err) => {\n console.log(`${file} ${err ? 'is not' : 'is'} readable and writable`);\n});\n</code></pre>\n<p>Do not use <code>fs.access()</code> to check for the accessibility of a file before calling\n<code>fs.open()</code>, <code>fs.readFile()</code>, or <code>fs.writeFile()</code>. Doing\nso introduces a race condition, since other processes may change the file's\nstate between the two calls. Instead, user code should open/read/write the\nfile directly and handle the error raised if the file is not accessible.</p>\n<p><strong>write (NOT RECOMMENDED)</strong></p>\n<pre><code class=\"language-mjs\">import { access, open, close } from 'node:fs';\n\naccess('myfile', (err) => {\n if (!err) {\n console.error('myfile already exists');\n return;\n }\n\n open('myfile', 'wx', (err, fd) => {\n if (err) throw err;\n\n try {\n writeMyData(fd);\n } finally {\n close(fd, (err) => {\n if (err) throw err;\n });\n }\n });\n});\n</code></pre>\n<p><strong>write (RECOMMENDED)</strong></p>\n<pre><code class=\"language-mjs\">import { open, close } from 'node:fs';\n\nopen('myfile', 'wx', (err, fd) => {\n if (err) {\n if (err.code === 'EEXIST') {\n console.error('myfile already exists');\n return;\n }\n\n throw err;\n }\n\n try {\n writeMyData(fd);\n } finally {\n close(fd, (err) => {\n if (err) throw err;\n });\n }\n});\n</code></pre>\n<p><strong>read (NOT RECOMMENDED)</strong></p>\n<pre><code class=\"language-mjs\">import { access, open, close } from 'node:fs';\naccess('myfile', (err) => {\n if (err) {\n if (err.code === 'ENOENT') {\n console.error('myfile does not exist');\n return;\n }\n\n throw err;\n }\n\n open('myfile', 'r', (err, fd) => {\n if (err) throw err;\n\n try {\n readMyData(fd);\n } finally {\n close(fd, (err) => {\n if (err) throw err;\n });\n }\n });\n});\n</code></pre>\n<p><strong>read (RECOMMENDED)</strong></p>\n<pre><code class=\"language-mjs\">import { open, close } from 'node:fs';\n\nopen('myfile', 'r', (err, fd) => {\n if (err) {\n if (err.code === 'ENOENT') {\n console.error('myfile does not exist');\n return;\n }\n\n throw err;\n }\n\n try {\n readMyData(fd);\n } finally {\n close(fd, (err) => {\n if (err) throw err;\n });\n }\n});\n</code></pre>\n<p>The \"not recommended\" examples above check for accessibility and then use the\nfile; the \"recommended\" examples are better because they use the file directly\nand handle the error, if any.</p>\n<p>In general, check for the accessibility of a file only if the file will not be\nused directly, for example when its accessibility is a signal from another\nprocess.</p>\n<p>On Windows, access-control policies (ACLs) on a directory may limit access to\na file or directory. The <code>fs.access()</code> function, however, does not check the\nACL and therefore may report that a path is accessible even if the ACL restricts\nthe user from reading or writing to it.</p>"
2878 "textRaw": "`fs.appendFile(path, data[, options], callback)`",
2917 "textRaw": "`path` {string|Buffer|URL|number} filename or file descriptor",
2918 "name": "path",
2968 "desc": "<p>Asynchronously append data to a file, creating the file if it does not yet\nexist. <code>data</code> can be a string or a <a href=\"buffer.html#class-buffer\" class=\"type\">&lt;Buffer&gt;</a>.</p>\n<p>The <code>mode</code> option only affects the newly created file. See <a href=\"#fsopenpath-flags-mode-callback\"><code>fs.open()</code></a>\nfor more details.</p>\n<pre><code class=\"language-mjs\">import { appendFile } from 'node:fs';\n\nappendFile('message.txt', 'data to append', (err) => {\n if (err) throw err;\n console.log('The \"data to append\" was appended to file!');\n});\n</code></pre>\n<p>If <code>options</code> is a string, then it specifies the encoding:</p>\n<pre><code class=\"language-mjs\">import { appendFile } from 'node:fs';\n\nappendFile('message.txt', 'data to append', 'utf8', callback);\n</code></pre>\n<p>The <code>path</code> may be specified as a numeric file descriptor that has been opened\nfor appending (using <code>fs.open()</code> or <code>fs.openSync()</code>). The file descriptor will\nnot be closed automatically.</p>\n<pre><code class=\"language-mjs\">import { open, close, appendFile } from 'node:fs';\n\nfunction closeFd(fd) {\n close(fd, (err) => {\n if (err) throw err;\n });\n}\n\nopen('message.txt', 'a', (err, fd) => {\n if (err) throw err;\n\n try {\n appendFile(fd, 'data to append', 'utf8', (err) => {\n closeFd(fd);\n if (err) throw err;\n });\n } catch (err) {\n closeFd(fd);\n throw err;\n }\n});\n</code></pre>"
2971 "textRaw": "`fs.chmod(path, mode, callback)`",
2992 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
3005 "textRaw": "`path` {string|Buffer|URL}",
3006 "name": "path",
3041 "textRaw": "`fs.chown(path, uid, gid, callback)`",
3062 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
3075 "textRaw": "`path` {string|Buffer|URL}",
3076 "name": "path",
3240 "description": "Accepts an additional `verbatimSymlinks` option to specify whether to perform path resolution for symlinks."
3250 "textRaw": "`src` {string|URL} source path to copy.",
3253 "desc": "source path to copy."
3256 "textRaw": "`dest` {string|URL} destination path to copy to.",
3259 "desc": "destination path to copy to."
3288 "textRaw": "`src` {string} source path to copy.",
3291 "desc": "source path to copy."
3294 "textRaw": "`dest` {string} destination path to copy to.",
3297 "desc": "destination path to copy to."
3335 "textRaw": "`verbatimSymlinks` {boolean} When `true`, path resolution for symlinks will be skipped. **Default:** `false`",
3339 "desc": "When `true`, path resolution for symlinks will be skipped."
3354 "textRaw": "`fs.createReadStream(path[, options])`",
3410 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
3433 "textRaw": "`path` {string|Buffer|URL}",
3434 "name": "path",
3513 "desc": "<p>Unlike the 16 KiB default <code>highWaterMark</code> for a <a href=\"stream.html#class-streamreadable\" class=\"type\">&lt;stream.Readable&gt;</a>, the stream\nreturned by this method has a default <code>highWaterMark</code> of 64 KiB.</p>\n<p><code>options</code> can include <code>start</code> and <code>end</code> values to read a range of bytes from\nthe file instead of the entire file. Both <code>start</code> and <code>end</code> are inclusive and\nstart counting at 0, allowed values are in the\n[0, <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER\"><code>Number.MAX_SAFE_INTEGER</code></a>] range. If <code>fd</code> is specified and <code>start</code> is\nomitted or <code>undefined</code>, <code>fs.createReadStream()</code> reads sequentially from the\ncurrent file position. The <code>encoding</code> can be any one of those accepted by\n<a href=\"buffer.html#class-buffer\" class=\"type\">&lt;Buffer&gt;</a>.</p>\n<p>If <code>fd</code> is specified, <code>ReadStream</code> will ignore the <code>path</code> argument and will use\nthe specified file descriptor. This means that no <code>'open'</code> event will be\nemitted. <code>fd</code> should be blocking; non-blocking <code>fd</code>s should be passed to\n<a href=\"net.html#class-netsocket\" class=\"type\">&lt;net.Socket&gt;</a>.</p>\n<p>If <code>fd</code> points to a character device that only supports blocking reads\n(such as keyboard or sound card), read operations do not finish until data is\navailable. This can prevent the process from exiting and the stream from\nclosing naturally.</p>\n<p>By default, the stream will emit a <code>'close'</code> event after it has been\ndestroyed. Set the <code>emitClose</code> option to <code>false</code> to change this behavior.</p>\n<p>By providing the <code>fs</code> option, it is possible to override the corresponding <code>fs</code>\nimplementations for <code>open</code>, <code>read</code>, and <code>close</code>. When providing the <code>fs</code> option,\nan override for <code>read</code> is required. If no <code>fd</code> is provided, an override for\n<code>open</code> is also required. If <code>autoClose</code> is <code>true</code>, an override for <code>close</code> is\nalso required.</p>\n<pre><code class=\"language-mjs\">import { createReadStream } from 'node:fs';\n\n// Create a stream from some character device.\nconst stream = createReadStream('/dev/input/event0');\nsetTimeout(() => {\n stream.close(); // This may not close the stream.\n // Artificially marking end-of-stream, as if the underlying resource had\n // indicated end-of-file by itself, allows the stream to close.\n // This does not cancel pending read operations, and if there is such an\n // operation, the process may still not be able to exit successfully\n // until it finishes.\n stream.push(null);\n stream.read(0);\n}, 100);\n</code></pre>\n<p>If <code>autoClose</code> is false, then the file descriptor won't be closed, even if\nthere's an error. It is the application's responsibility to close it and make\nsure there's no file descriptor leak. If <code>autoClose</code> is set to true (default\nbehavior), on <code>'error'</code> or <code>'end'</code> the file descriptor will be closed\nautomatically.</p>\n<p><code>mode</code> sets the file mode (permission and sticky bits), but only if the\nfile was created.</p>\n<p>An example to read the last 10 bytes of a file which is 100 bytes long:</p>\n<pre><code class=\"language-mjs\">import { createReadStream } from 'node:fs';\n\ncreateReadStream('sample.txt', { start: 90, end: 99 });\n</code></pre>\n<p>If <code>options</code> is a string, then it specifies the encoding.</p>"
3516 "textRaw": "`fs.createWriteStream(path[, options])`",
3567 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
3595 "textRaw": "`path` {string|Buffer|URL}",
3596 "name": "path",
3663 "desc": "<p><code>options</code> may also include a <code>start</code> option to allow writing data at some\nposition past the beginning of the file, allowed values are in the\n[0, <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER\"><code>Number.MAX_SAFE_INTEGER</code></a>] range. Modifying a file rather than\nreplacing it may require the <code>flags</code> option to be set to <code>r+</code> rather than the\ndefault <code>w</code>. The <code>encoding</code> can be any one of those accepted by <a href=\"buffer.html#class-buffer\" class=\"type\">&lt;Buffer&gt;</a>.</p>\n<p>If <code>autoClose</code> is set to true (default behavior) on <code>'error'</code> or <code>'finish'</code>\nthe file descriptor will be closed automatically. If <code>autoClose</code> is false,\nthen the file descriptor won't be closed, even if there's an error.\nIt is the application's responsibility to close it and make sure there's no\nfile descriptor leak.</p>\n<p>By default, the stream will emit a <code>'close'</code> event after it has been\ndestroyed. Set the <code>emitClose</code> option to <code>false</code> to change this behavior.</p>\n<p>By providing the <code>fs</code> option it is possible to override the corresponding <code>fs</code>\nimplementations for <code>open</code>, <code>write</code>, <code>writev</code>, and <code>close</code>. Overriding <code>write()</code>\nwithout <code>writev()</code> can reduce performance as some optimizations (<code>_writev()</code>)\nwill be disabled. When providing the <code>fs</code> option, overrides for at least one of\n<code>write</code> and <code>writev</code> are required. If no <code>fd</code> option is supplied, an override\nfor <code>open</code> is also required. If <code>autoClose</code> is <code>true</code>, an override for <code>close</code>\nis also required.</p>\n<p>Like <a href=\"fs.html#class-fsreadstream\" class=\"type\">&lt;fs.ReadStream&gt;</a>, if <code>fd</code> is specified, <a href=\"fs.html#class-fswritestream\" class=\"type\">&lt;fs.WriteStream&gt;</a> will ignore the\n<code>path</code> argument and will use the specified file descriptor. This means that no\n<code>'open'</code> event will be emitted. <code>fd</code> should be blocking; non-blocking <code>fd</code>s\nshould be passed to <a href=\"net.html#class-netsocket\" class=\"type\">&lt;net.Socket&gt;</a>.</p>\n<p>If <code>options</code> is a string, then it specifies the encoding.</p>"
3666 "textRaw": "`fs.exists(path, callback)`",
3685 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
3695 "textRaw": "`path` {string|Buffer|URL}",
3696 "name": "path",
3714 "desc": "<p>Test whether or not the given path exists by checking with the file system.\nThen call the <code>callback</code> argument with either true or false:</p>\n<pre><code class=\"language-mjs\">import { exists } from 'node:fs';\n\nexists('/etc/passwd', (e) => {\n console.log(e ? 'it exists' : 'no passwd!');\n});\n</code></pre>\n<p><strong>The parameters for this callback are not consistent with other Node.js\ncallbacks.</strong> Normally, the first parameter to a Node.js callback is an <code>err</code>\nparameter, optionally followed by other parameters. The <code>fs.exists()</code> callback\nhas only one boolean parameter. This is one reason <code>fs.access()</code> is recommended\ninstead of <code>fs.exists()</code>.</p>\n<p>Using <code>fs.exists()</code> to check for the existence of a file before calling\n<code>fs.open()</code>, <code>fs.readFile()</code>, or <code>fs.writeFile()</code> is not recommended. Doing\nso introduces a race condition, since other processes may change the file's\nstate between the two calls. Instead, user code should open/read/write the\nfile directly and handle the error raised if the file does not exist.</p>\n<p><strong>write (NOT RECOMMENDED)</strong></p>\n<pre><code class=\"language-mjs\">import { exists, open, close } from 'node:fs';\n\nexists('myfile', (e) => {\n if (e) {\n console.error('myfile already exists');\n } else {\n open('myfile', 'wx', (err, fd) => {\n if (err) throw err;\n\n try {\n writeMyData(fd);\n } finally {\n close(fd, (err) => {\n if (err) throw err;\n });\n }\n });\n }\n});\n</code></pre>\n<p><strong>write (RECOMMENDED)</strong></p>\n<pre><code class=\"language-mjs\">import { open, close } from 'node:fs';\nopen('myfile', 'wx', (err, fd) => {\n if (err) {\n if (err.code === 'EEXIST') {\n console.error('myfile already exists');\n return;\n }\n\n throw err;\n }\n\n try {\n writeMyData(fd);\n } finally {\n close(fd, (err) => {\n if (err) throw err;\n });\n }\n});\n</code></pre>\n<p><strong>read (NOT RECOMMENDED)</strong></p>\n<pre><code class=\"language-mjs\">import { open, close, exists } from 'node:fs';\n\nexists('myfile', (e) => {\n if (e) {\n open('myfile', 'r', (err, fd) => {\n if (err) throw err;\n\n try {\n readMyData(fd);\n } finally {\n close(fd, (err) => {\n if (err) throw err;\n });\n }\n });\n } else {\n console.error('myfile does not exist');\n }\n});\n</code></pre>\n<p><strong>read (RECOMMENDED)</strong></p>\n<pre><code class=\"language-mjs\">import { open, close } from 'node:fs';\n\nopen('myfile', 'r', (err, fd) => {\n if (err) {\n if (err.code === 'ENOENT') {\n console.error('myfile does not exist');\n return;\n }\n\n throw err;\n }\n\n try {\n readMyData(fd);\n } finally {\n close(fd, (err) => {\n if (err) throw err;\n });\n }\n});\n</code></pre>\n<p>The \"not recommended\" examples above check for existence and then use the\nfile; the \"recommended\" examples are better because they use the file directly\nand handle the error, if any.</p>\n<p>In general, check for the existence of a file only if the file won't be\nused directly, for example when its existence is a signal from another\nprocess.</p>"
4134 "textRaw": "`fs.lchmod(path, mode, callback)`",
4168 "textRaw": "`path` {string|Buffer|URL}",
4169 "name": "path",
4195 "textRaw": "`fs.lchown(path, uid, gid, callback)`",
4230 "textRaw": "`path` {string|Buffer|URL}",
4231 "name": "path",
4262 "textRaw": "`fs.lutimes(path, atime, mtime, callback)`",
4282 "textRaw": "`path` {string|Buffer|URL}",
4283 "name": "path",
4311 "desc": "<p>Changes the access and modification times of a file in the same way as\n<a href=\"#fsutimespath-atime-mtime-callback\"><code>fs.utimes()</code></a>, with the difference that if the path refers to a symbolic\nlink, then the link is not dereferenced: instead, the timestamps of the\nsymbolic link itself are changed.</p>\n<p>No arguments other than a possible exception are given to the completion\ncallback.</p>"
4375 "textRaw": "`fs.lstat(path[, options], callback)`",
4401 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
4414 "textRaw": "`path` {string|Buffer|URL}",
4415 "name": "path",
4452 "desc": "<p>Retrieves the <a href=\"fs.html#class-fsstats\" class=\"type\">&lt;fs.Stats&gt;</a> for the symbolic link referred to by the path.\nThe callback gets two arguments <code>(err, stats)</code> where <code>stats</code> is a <a href=\"fs.html#class-fsstats\" class=\"type\">&lt;fs.Stats&gt;</a>\nobject. <code>lstat()</code> is identical to <code>stat()</code>, except that if <code>path</code> is a symbolic\nlink, then the link itself is stat-ed, not the file that it refers to.</p>\n<p>See the POSIX <a href=\"http://man7.org/linux/man-pages/man2/lstat.2.html\"><code>lstat(2)</code></a> documentation for more details.</p>"
4455 "textRaw": "`fs.mkdir(path[, options], callback)`",
4474 "description": "In `recursive` mode, the callback now receives the first created path as an argument."
4489 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
4502 "textRaw": "`path` {string|Buffer|URL}",
4503 "name": "path",
4537 "textRaw": "`path` {string|undefined} Present only if a directory is created with `recursive` set to `true`.",
4538 "name": "path",
4547 "desc": "<p>Asynchronously creates a directory.</p>\n<p>The callback is given a possible exception and, if <code>recursive</code> is <code>true</code>, the\nfirst directory path created, <code>(err[, path])</code>.\n<code>path</code> can still be <code>undefined</code> when <code>recursive</code> is <code>true</code>, if no directory was\ncreated (for instance, if it was previously created).</p>\n<p>The optional <code>options</code> argument can be an integer specifying <code>mode</code> (permission\nand sticky bits), or an object with a <code>mode</code> property and a <code>recursive</code>\nproperty indicating whether parent directories should be created. Calling\n<code>fs.mkdir()</code> when <code>path</code> is a directory that exists results in an error only\nwhen <code>recursive</code> is false. If <code>recursive</code> is false and the directory exists,\nan <code>EEXIST</code> error occurs.</p>\n<pre><code class=\"language-mjs\">import { mkdir } from 'node:fs';\n\n// Create ./tmp/a/apple, regardless of whether ./tmp and ./tmp/a exist.\nmkdir('./tmp/a/apple', { recursive: true }, (err) => {\n if (err) throw err;\n});\n</code></pre>\n<p>On Windows, using <code>fs.mkdir()</code> on the root directory even with recursion will\nresult in an error:</p>\n<pre><code class=\"language-mjs\">import { mkdir } from 'node:fs';\n\nmkdir('/', { recursive: true }, (err) => {\n // => [Error: EPERM: operation not permitted, mkdir 'C:\\']\n});\n</code></pre>\n<p>See the POSIX <a href=\"http://man7.org/linux/man-pages/man2/mkdir.2.html\"><code>mkdir(2)</code></a> documentation for more details.</p>"
4634 "desc": "<p>Creates a unique temporary directory.</p>\n<p>Generates six random characters to be appended behind a required\n<code>prefix</code> to create a unique temporary directory. Due to platform\ninconsistencies, avoid trailing <code>X</code> characters in <code>prefix</code>. Some platforms,\nnotably the BSDs, can return more than six random characters, and replace\ntrailing <code>X</code> characters in <code>prefix</code> with random characters.</p>\n<p>The created directory path is passed as a string to the callback's second\nparameter.</p>\n<p>The optional <code>options</code> argument can be a string specifying an encoding, or an\nobject with an <code>encoding</code> property specifying the character encoding to use.</p>\n<pre><code class=\"language-mjs\">import { mkdtemp } from 'node:fs';\nimport { join } from 'node:path';\nimport { tmpdir } from 'node:os';\n\nmkdtemp(join(tmpdir(), 'foo-'), (err, directory) => {\n if (err) throw err;\n console.log(directory);\n // Prints: /tmp/foo-itXde2 or C:\\Users\\...\\AppData\\Local\\Temp\\foo-itXde2\n});\n</code></pre>\n<p>The <code>fs.mkdtemp()</code> method will append the six randomly selected characters\ndirectly to the <code>prefix</code> string. For instance, given a directory <code>/tmp</code>, if the\nintention is to create a temporary directory <em>within</em> <code>/tmp</code>, the <code>prefix</code>\nmust end with a trailing platform-specific path separator\n(<code>require('node:path').sep</code>).</p>\n<pre><code class=\"language-mjs\">import { tmpdir } from 'node:os';\nimport { mkdtemp } from 'node:fs';\n\n// The parent directory for the new temporary directory\nconst tmpDir = tmpdir();\n\n// This method is *INCORRECT*:\nmkdtemp(tmpDir, (err, directory) => {\n if (err) throw err;\n console.log(directory);\n // Will print something similar to `/tmpabc123`.\n // A new temporary directory is created at the file system root\n // rather than *within* the /tmp directory.\n});\n\n// This method is *CORRECT*:\nimport { sep } from 'node:path';\nmkdtemp(`${tmpDir}${sep}`, (err, directory) => {\n if (err) throw err;\n console.log(directory);\n // Will print something similar to `/tmp/abc123`.\n // A new temporary directory is created within\n // the /tmp directory.\n});\n</code></pre>"
4637 "textRaw": "`fs.open(path[, flags[, mode]], callback)`",
4663 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
4671 "textRaw": "`path` {string|Buffer|URL}",
4672 "name": "path",
4711 "textRaw": "`fs.opendir(path[, options], callback)`",
4743 "textRaw": "`path` {string|Buffer|URL}",
4744 "name": "path",
4793 "desc": "<p>Asynchronously open a directory. See the POSIX <a href=\"http://man7.org/linux/man-pages/man3/opendir.3.html\"><code>opendir(3)</code></a> documentation for\nmore details.</p>\n<p>Creates an <a href=\"fs.html#class-fsdir\" class=\"type\">&lt;fs.Dir&gt;</a>, which contains all further functions for reading from\nand cleaning up the directory.</p>\n<p>The <code>encoding</code> option sets the encoding for the <code>path</code> while opening the\ndirectory and subsequent read operations.</p>"
5048 "textRaw": "`fs.readdir(path[, options], callback)`",
5079 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
5097 "textRaw": "`path` {string|Buffer|URL}",
5098 "name": "path",
5149 "textRaw": "`fs.readFile(path[, options], callback)`",
5183 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
5198 "description": "The `path` parameter can be a file descriptor now."
5206 "textRaw": "`path` {string|Buffer|URL|integer} filename or file descriptor",
5207 "name": "path",
5257 "desc": "<p>Asynchronously reads the entire contents of a file.</p>\n<pre><code class=\"language-mjs\">import { readFile } from 'node:fs';\n\nreadFile('/etc/passwd', (err, data) => {\n if (err) throw err;\n console.log(data);\n});\n</code></pre>\n<p>The callback is passed two arguments <code>(err, data)</code>, where <code>data</code> is the\ncontents of the file.</p>\n<p>If no encoding is specified, then the raw buffer is returned.</p>\n<p>If <code>options</code> is a string, then it specifies the encoding:</p>\n<pre><code class=\"language-mjs\">import { readFile } from 'node:fs';\n\nreadFile('/etc/passwd', 'utf8', callback);\n</code></pre>\n<p>When the path is a directory, the behavior of <code>fs.readFile()</code> and\n<a href=\"#fsreadfilesyncpath-options\"><code>fs.readFileSync()</code></a> is platform-specific. On macOS, Linux, and Windows, an\nerror will be returned. On FreeBSD, a representation of the directory's contents\nwill be returned.</p>\n<pre><code class=\"language-mjs\">import { readFile } from 'node:fs';\n\n// macOS, Linux, and Windows\nreadFile('&#x3C;directory>', (err, data) => {\n // => [Error: EISDIR: illegal operation on a directory, read &#x3C;directory>]\n});\n\n// FreeBSD\nreadFile('&#x3C;directory>', (err, data) => {\n // => null, &#x3C;data>\n});\n</code></pre>\n<p>It is possible to abort an ongoing request using an <code>AbortSignal</code>. If a\nrequest is aborted the callback is called with an <code>AbortError</code>:</p>\n<pre><code class=\"language-mjs\">import { readFile } from 'node:fs';\n\nconst controller = new AbortController();\nconst signal = controller.signal;\nreadFile(fileInfo[0].name, { signal }, (err, buf) => {\n // ...\n});\n// When you want to abort the request\ncontroller.abort();\n</code></pre>\n<p>The <code>fs.readFile()</code> function buffers the entire file. To minimize memory costs,\nwhen possible prefer streaming via <code>fs.createReadStream()</code>.</p>\n<p>Aborting an ongoing request does not abort individual operating\nsystem requests but rather the internal buffering <code>fs.readFile</code> performs.</p>",
5262 "desc": "<ol>\n<li>Any specified file descriptor has to support reading.</li>\n<li>If a file descriptor is specified as the <code>path</code>, it will not be closed\nautomatically.</li>\n<li>The reading will begin at the current position. For example, if the file\nalready had <code>'Hello World</code>' and six bytes are read with the file descriptor,\nthe call to <code>fs.readFile()</code> with the same file descriptor, would give\n<code>'World'</code>, rather than <code>'Hello World'</code>.</li>\n</ol>",
5276 "textRaw": "`fs.readlink(path[, options], callback)`",
5297 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
5310 "textRaw": "`path` {string|Buffer|URL}",
5311 "name": "path",
5347 "desc": "<p>Reads the contents of the symbolic link referred to by <code>path</code>. The callback gets\ntwo arguments <code>(err, linkString)</code>.</p>\n<p>See the POSIX <a href=\"http://man7.org/linux/man-pages/man2/readlink.2.html\"><code>readlink(2)</code></a> documentation for more details.</p>\n<p>The optional <code>options</code> argument can be a string specifying an encoding, or an\nobject with an <code>encoding</code> property specifying the character encoding to use for\nthe link path passed to the callback. If the <code>encoding</code> is set to <code>'buffer'</code>,\nthe link path returned will be passed as a <a href=\"buffer.html#class-buffer\" class=\"type\">&lt;Buffer&gt;</a> object.</p>"
5413 "textRaw": "`fs.realpath(path[, options], callback)`",
5439 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
5462 "textRaw": "`path` {string|Buffer|URL}",
5463 "name": "path",
5499 "desc": "<p>Asynchronously computes the canonical pathname by resolving <code>.</code>, <code>..</code>, and\nsymbolic links.</p>\n<p>A canonical pathname is not necessarily unique. Hard links and bind mounts can\nexpose a file system entity through many pathnames.</p>\n<p>This function behaves like <a href=\"http://man7.org/linux/man-pages/man3/realpath.3.html\"><code>realpath(3)</code></a>, with some exceptions:</p>\n<ol>\n<li>\n<p>No case conversion is performed on case-insensitive file systems.</p>\n</li>\n<li>\n<p>The maximum number of symbolic links is platform-independent and generally\n(much) higher than what the native <a href=\"http://man7.org/linux/man-pages/man3/realpath.3.html\"><code>realpath(3)</code></a> implementation supports.</p>\n</li>\n</ol>\n<p>The <code>callback</code> gets two arguments <code>(err, resolvedPath)</code>. May use <code>process.cwd</code>\nto resolve relative paths.</p>\n<p>Only paths that can be converted to UTF8 strings are supported.</p>\n<p>The optional <code>options</code> argument can be a string specifying an encoding, or an\nobject with an <code>encoding</code> property specifying the character encoding to use for\nthe path passed to the callback. If the <code>encoding</code> is set to <code>'buffer'</code>,\nthe path returned will be passed as a <a href=\"buffer.html#class-buffer\" class=\"type\">&lt;Buffer&gt;</a> object.</p>\n<p>If <code>path</code> resolves to a socket or a pipe, the function will return a system\ndependent name for that object.</p>"
5502 "textRaw": "`fs.realpath.native(path[, options], callback)`",
5521 "textRaw": "`path` {string|Buffer|URL}",
5522 "name": "path",
5558 "desc": "<p>Asynchronous <a href=\"http://man7.org/linux/man-pages/man3/realpath.3.html\"><code>realpath(3)</code></a>.</p>\n<p>The <code>callback</code> gets two arguments <code>(err, resolvedPath)</code>.</p>\n<p>Only paths that can be converted to UTF8 strings are supported.</p>\n<p>The optional <code>options</code> argument can be a string specifying an encoding, or an\nobject with an <code>encoding</code> property specifying the character encoding to use for\nthe path passed to the callback. If the <code>encoding</code> is set to <code>'buffer'</code>,\nthe path returned will be passed as a <a href=\"buffer.html#class-buffer\" class=\"type\">&lt;Buffer&gt;</a> object.</p>\n<p>On Linux, when Node.js is linked against musl libc, the procfs file system must\nbe mounted on <code>/proc</code> in order for this function to work. Glibc does not have\nthis restriction.</p>"
5622 "textRaw": "`fs.rmdir(path[, options], callback)`",
5638 "description": "Using `fs.rmdir(path, { recursive: true })` on a `path` that is a file is no longer permitted and results in an `ENOENT` error on Windows and an `ENOTDIR` error on POSIX."
5643 "description": "Using `fs.rmdir(path, { recursive: true })` on a `path` that does not exist is no longer permitted and results in a `ENOENT` error."
5676 "description": "The `path` parameters can be a WHATWG `URL` object using `file:` protocol."
5689 "textRaw": "`path` {string|Buffer|URL}",
5690 "name": "path",
5739 "textRaw": "`fs.rm(path[, options], callback)`",
5753 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
5761 "textRaw": "`path` {string|Buffer|URL}",
5762 "name": "path",
5771 "textRaw": "`force` {boolean} When `true`, exceptions will be ignored if `path` does not exist. **Default:** `false`.",
5775 "desc": "When `true`, exceptions will be ignored if `path` does not exist."
5818 "textRaw": "`fs.stat(path[, options], callback)`",
5844 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
5857 "textRaw": "`path` {string|Buffer|URL}",
5858 "name": "path",
5898 "textRaw": "`fs.statfs(path[, options], callback)`",
5911 "textRaw": "`path` {string|Buffer|URL}",
5912 "name": "path",
5949 "desc": "<p>Asynchronous <a href=\"http://man7.org/linux/man-pages/man2/statfs.2.html\"><code>statfs(2)</code></a>. Returns information about the mounted file system which\ncontains <code>path</code>. The callback gets two arguments <code>(err, stats)</code> where <code>stats</code>\nis an <a href=\"fs.html#class-fsstatfs\" class=\"type\">&lt;fs.StatFs&gt;</a> object.</p>\n<p>In case of an error, the <code>err.code</code> will be one of <a href=\"errors.html#common-system-errors\">Common System Errors</a>.</p>"
5952 "textRaw": "`fs.symlink(target, path[, type], callback)`",
5973 "description": "The `target` and `path` parameters can be WHATWG `URL` objects using `file:` protocol. Support is currently still *experimental*."
5986 "textRaw": "`path` {string|Buffer|URL}",
5987 "name": "path",
6011 "desc": "<p>Creates the link called <code>path</code> pointing to <code>target</code>. No arguments other than a\npossible exception are given to the completion callback.</p>\n<p>See the POSIX <a href=\"http://man7.org/linux/man-pages/man2/symlink.2.html\"><code>symlink(2)</code></a> documentation for more details.</p>\n<p>The <code>type</code> argument is only available on Windows and ignored on other platforms.\nIt can be set to <code>'dir'</code>, <code>'file'</code>, or <code>'junction'</code>. If the <code>type</code> argument is\nnot a string, Node.js will autodetect <code>target</code> type and use <code>'file'</code> or <code>'dir'</code>.\nIf the <code>target</code> does not exist, <code>'file'</code> will be used. Windows junction points\nrequire the destination path to be absolute. When using <code>'junction'</code>, the\n<code>target</code> argument will automatically be normalized to absolute path. Junction\npoints on NTFS volumes can only point to directories.</p>\n<p>Relative targets are relative to the link's parent directory.</p>\n<pre><code class=\"language-mjs\">import { symlink } from 'node:fs';\n\nsymlink('./mew', './mewtwo', callback);\n</code></pre>\n<p>The above example creates a symbolic link <code>mewtwo</code> which points to <code>mew</code> in the\nsame directory:</p>\n<pre><code class=\"language-bash\">$ tree .\n.\n├── mew\n└── mewtwo -> ./mew\n</code></pre>"
6014 "textRaw": "`fs.truncate(path[, len], callback)`",
6048 "textRaw": "`path` {string|Buffer|URL}",
6049 "name": "path",
6073 "desc": "<p>Truncates the file. No arguments other than a possible exception are\ngiven to the completion callback. A file descriptor can also be passed as the\nfirst argument. In this case, <code>fs.ftruncate()</code> is called.</p>\n<pre><code class=\"language-mjs\">import { truncate } from 'node:fs';\n// Assuming that 'path/file.txt' is a regular file.\ntruncate('path/file.txt', (err) => {\n if (err) throw err;\n console.log('path/file.txt was truncated');\n});\n</code></pre>\n<pre><code class=\"language-cjs\">const { truncate } = require('node:fs');\n// Assuming that 'path/file.txt' is a regular file.\ntruncate('path/file.txt', (err) => {\n if (err) throw err;\n console.log('path/file.txt was truncated');\n});\n</code></pre>\n<p>Passing a file descriptor is deprecated and may result in an error being thrown\nin the future.</p>\n<p>See the POSIX <a href=\"http://man7.org/linux/man-pages/man2/truncate.2.html\"><code>truncate(2)</code></a> documentation for more details.</p>"
6076 "textRaw": "`fs.unlink(path, callback)`",
6097 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
6110 "textRaw": "`path` {string|Buffer|URL}",
6111 "name": "path",
6129 "desc": "<p>Asynchronously removes a file or symbolic link. No arguments other than a\npossible exception are given to the completion callback.</p>\n<pre><code class=\"language-mjs\">import { unlink } from 'node:fs';\n// Assuming that 'path/file.txt' is a regular file.\nunlink('path/file.txt', (err) => {\n if (err) throw err;\n console.log('path/file.txt was deleted');\n});\n</code></pre>\n<p><code>fs.unlink()</code> will not work on a directory, empty or otherwise. To remove a\ndirectory, use <a href=\"#fsrmdirpath-options-callback\"><code>fs.rmdir()</code></a>.</p>\n<p>See the POSIX <a href=\"http://man7.org/linux/man-pages/man2/unlink.2.html\"><code>unlink(2)</code></a> documentation for more details.</p>"
6161 "textRaw": "`fs.utimes(path, atime, mtime, callback)`",
6187 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
6205 "textRaw": "`path` {string|Buffer|URL}",
6206 "name": "path",
6234 "desc": "<p>Change the file system timestamps of the object referenced by <code>path</code>.</p>\n<p>The <code>atime</code> and <code>mtime</code> arguments follow these rules:</p>\n<ul>\n<li>Values can be either numbers representing Unix epoch time in seconds,\n<code>Date</code>s, or a numeric string like <code>'123456789.0'</code>.</li>\n<li>If the value can not be converted to a number, or is <code>NaN</code>, <code>Infinity</code>, or\n<code>-Infinity</code>, an <code>Error</code> will be thrown.</li>\n</ul>"
6351 "desc": "<p>On Linux and macOS systems, <code>fs.watch()</code> resolves the path to an <a href=\"https://en.wikipedia.org/wiki/Inode\">inode</a> and\nwatches the inode. If the watched path is deleted and recreated, it is assigned\na new inode. The watch will emit an event for the delete but will continue\nwatching the <em>original</em> inode. Events for the new inode will not be emitted.\nThis is expected behavior.</p>\n<p>AIX files retain the same inode for the lifetime of a file. Saving and closing a\nwatched file on AIX will result in two notifications (one for adding new\ncontent, and one for truncation).</p>"
6929 "textRaw": "`fs.accessSync(path[, mode])`",
6940 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
6948 "textRaw": "`path` {string|Buffer|URL}",
6949 "name": "path",
6961 "desc": "<p>Synchronously tests a user's permissions for the file or directory specified\nby <code>path</code>. The <code>mode</code> argument is an optional integer that specifies the\naccessibility checks to be performed. <code>mode</code> should be either the value\n<code>fs.constants.F_OK</code> or a mask consisting of the bitwise OR of any of\n<code>fs.constants.R_OK</code>, <code>fs.constants.W_OK</code>, and <code>fs.constants.X_OK</code> (e.g.\n<code>fs.constants.W_OK | fs.constants.R_OK</code>). Check <a href=\"#file-access-constants\">File access constants</a> for\npossible values of <code>mode</code>.</p>\n<p>If any of the accessibility checks fail, an <code>Error</code> will be thrown. Otherwise,\nthe method will return <code>undefined</code>.</p>\n<pre><code class=\"language-mjs\">import { accessSync, constants } from 'node:fs';\n\ntry {\n accessSync('etc/passwd', constants.R_OK | constants.W_OK);\n console.log('can read/write');\n} catch (err) {\n console.error('no access!');\n}\n</code></pre>"
6964 "textRaw": "`fs.appendFileSync(path, data[, options])`",
6988 "textRaw": "`path` {string|Buffer|URL|number} filename or file descriptor",
6989 "name": "path",
7027 "desc": "<p>Synchronously append data to a file, creating the file if it does not yet\nexist. <code>data</code> can be a string or a <a href=\"buffer.html#class-buffer\" class=\"type\">&lt;Buffer&gt;</a>.</p>\n<p>The <code>mode</code> option only affects the newly created file. See <a href=\"#fsopenpath-flags-mode-callback\"><code>fs.open()</code></a>\nfor more details.</p>\n<pre><code class=\"language-mjs\">import { appendFileSync } from 'node:fs';\n\ntry {\n appendFileSync('message.txt', 'data to append');\n console.log('The \"data to append\" was appended to file!');\n} catch (err) {\n /* Handle the error */\n}\n</code></pre>\n<p>If <code>options</code> is a string, then it specifies the encoding:</p>\n<pre><code class=\"language-mjs\">import { appendFileSync } from 'node:fs';\n\nappendFileSync('message.txt', 'data to append', 'utf8');\n</code></pre>\n<p>The <code>path</code> may be specified as a numeric file descriptor that has been opened\nfor appending (using <code>fs.open()</code> or <code>fs.openSync()</code>). The file descriptor will\nnot be closed automatically.</p>\n<pre><code class=\"language-mjs\">import { openSync, closeSync, appendFileSync } from 'node:fs';\n\nlet fd;\n\ntry {\n fd = openSync('message.txt', 'a');\n appendFileSync(fd, 'data to append', 'utf8');\n} catch (err) {\n /* Handle the error */\n} finally {\n if (fd !== undefined)\n closeSync(fd);\n}\n</code></pre>"
7030 "textRaw": "`fs.chmodSync(path, mode)`",
7041 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
7049 "textRaw": "`path` {string|Buffer|URL}",
7050 "name": "path",
7064 "textRaw": "`fs.chownSync(path, uid, gid)`",
7075 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
7083 "textRaw": "`path` {string|Buffer|URL}",
7084 "name": "path",
7185 "description": "Accepts an additional `verbatimSymlinks` option to specify whether to perform path resolution for symlinks."
7195 "textRaw": "`src` {string|URL} source path to copy.",
7198 "desc": "source path to copy."
7201 "textRaw": "`dest` {string|URL} destination path to copy to.",
7204 "desc": "destination path to copy to."
7233 "textRaw": "`src` {string} source path to copy.",
7236 "desc": "source path to copy."
7239 "textRaw": "`dest` {string} destination path to copy to.",
7242 "desc": "destination path to copy to."
7280 "textRaw": "`verbatimSymlinks` {boolean} When `true`, path resolution for symlinks will be skipped. **Default:** `false`",
7284 "desc": "When `true`, path resolution for symlinks will be skipped."
7294 "textRaw": "`fs.existsSync(path)`",
7305 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
7318 "textRaw": "`path` {string|Buffer|URL}",
7319 "name": "path",
7325 "desc": "<p>Returns <code>true</code> if the path exists, <code>false</code> otherwise.</p>\n<p>For detailed information, see the documentation of the asynchronous version of\nthis API: <a href=\"#fsexistspath-callback\"><code>fs.exists()</code></a>.</p>\n<p><code>fs.exists()</code> is deprecated, but <code>fs.existsSync()</code> is not. The <code>callback</code>\nparameter to <code>fs.exists()</code> accepts parameters that are inconsistent with other\nNode.js callbacks. <code>fs.existsSync()</code> does not use a callback.</p>\n<pre><code class=\"language-mjs\">import { existsSync } from 'node:fs';\n\nif (existsSync('/etc/passwd'))\n console.log('The path exists.');\n</code></pre>"
7553 "textRaw": "`fs.lchmodSync(path, mode)`",
7566 "textRaw": "`path` {string|Buffer|URL}",
7567 "name": "path",
7581 "textRaw": "`fs.lchownSync(path, uid, gid)`",
7601 "textRaw": "`path` {string|Buffer|URL}",
7602 "name": "path",
7620 "desc": "<p>Set the owner for the path. Returns <code>undefined</code>.</p>\n<p>See the POSIX <a href=\"http://man7.org/linux/man-pages/man2/lchown.2.html\"><code>lchown(2)</code></a> documentation for more details.</p>"
7623 "textRaw": "`fs.lutimesSync(path, atime, mtime)`",
7637 "textRaw": "`path` {string|Buffer|URL}",
7638 "name": "path",
7654 "desc": "<p>Change the file system timestamps of the symbolic link referenced by <code>path</code>.\nReturns <code>undefined</code>, or throws an exception when parameters are incorrect or\nthe operation fails. This is the synchronous version of <a href=\"#fslutimespath-atime-mtime-callback\"><code>fs.lutimes()</code></a>.</p>"
7691 "textRaw": "`fs.lstatSync(path[, options])`",
7715 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
7728 "textRaw": "`path` {string|Buffer|URL}",
7729 "name": "path",
7756 "desc": "<p>Retrieves the <a href=\"fs.html#class-fsstats\" class=\"type\">&lt;fs.Stats&gt;</a> for the symbolic link referred to by <code>path</code>.</p>\n<p>See the POSIX <a href=\"http://man7.org/linux/man-pages/man2/lstat.2.html\"><code>lstat(2)</code></a> documentation for more details.</p>"
7759 "textRaw": "`fs.mkdirSync(path[, options])`",
7773 "description": "In `recursive` mode, the first created path is returned now."
7783 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
7796 "textRaw": "`path` {string|Buffer|URL}",
7797 "name": "path",
7823 "desc": "<p>Synchronously creates a directory. Returns <code>undefined</code>, or if <code>recursive</code> is\n<code>true</code>, the first directory path created.\nThis is the synchronous version of <a href=\"#fsmkdirpath-options-callback\"><code>fs.mkdir()</code></a>.</p>\n<p>See the POSIX <a href=\"http://man7.org/linux/man-pages/man2/mkdir.2.html\"><code>mkdir(2)</code></a> documentation for more details.</p>"
7878 "desc": "<p>Returns the created directory path.</p>\n<p>For detailed information, see the documentation of the asynchronous version of\nthis API: <a href=\"#fsmkdtempprefix-options-callback\"><code>fs.mkdtemp()</code></a>.</p>\n<p>The optional <code>options</code> argument can be a string specifying an encoding, or an\nobject with an <code>encoding</code> property specifying the character encoding to use.</p>"
7881 "textRaw": "`fs.opendirSync(path[, options])`",
7913 "textRaw": "`path` {string|Buffer|URL}",
7914 "name": "path",
7946 "desc": "<p>Synchronously open a directory. See <a href=\"http://man7.org/linux/man-pages/man3/opendir.3.html\"><code>opendir(3)</code></a>.</p>\n<p>Creates an <a href=\"fs.html#class-fsdir\" class=\"type\">&lt;fs.Dir&gt;</a>, which contains all further functions for reading from\nand cleaning up the directory.</p>\n<p>The <code>encoding</code> option sets the encoding for the <code>path</code> while opening the\ndirectory and subsequent read operations.</p>"
7949 "textRaw": "`fs.openSync(path[, flags[, mode]])`",
7970 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
7983 "textRaw": "`path` {string|Buffer|URL}",
7984 "name": "path",
8005 "textRaw": "`fs.readdirSync(path[, options])`",
8026 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
8039 "textRaw": "`path` {string|Buffer|URL}",
8040 "name": "path",
8074 "textRaw": "`fs.readFileSync(path[, options])`",
8085 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
8090 "description": "The `path` parameter can be a file descriptor now."
8103 "textRaw": "`path` {string|Buffer|URL|integer} filename or file descriptor",
8104 "name": "path",
8131 "desc": "<p>Returns the contents of the <code>path</code>.</p>\n<p>For detailed information, see the documentation of the asynchronous version of\nthis API: <a href=\"#fsreadfilepath-options-callback\"><code>fs.readFile()</code></a>.</p>\n<p>If the <code>encoding</code> option is specified then this function returns a\nstring. Otherwise it returns a buffer.</p>\n<p>Similar to <a href=\"#fsreadfilepath-options-callback\"><code>fs.readFile()</code></a>, when the path is a directory, the behavior of\n<code>fs.readFileSync()</code> is platform-specific.</p>\n<pre><code class=\"language-mjs\">import { readFileSync } from 'node:fs';\n\n// macOS, Linux, and Windows\nreadFileSync('&#x3C;directory>');\n// => [Error: EISDIR: illegal operation on a directory, read &#x3C;directory>]\n\n// FreeBSD\nreadFileSync('&#x3C;directory>'); // => &#x3C;data>\n</code></pre>"
8134 "textRaw": "`fs.readlinkSync(path[, options])`",
8145 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
8158 "textRaw": "`path` {string|Buffer|URL}",
8159 "name": "path",
8178 "desc": "<p>Returns the symbolic link's string value.</p>\n<p>See the POSIX <a href=\"http://man7.org/linux/man-pages/man2/readlink.2.html\"><code>readlink(2)</code></a> documentation for more details.</p>\n<p>The optional <code>options</code> argument can be a string specifying an encoding, or an\nobject with an <code>encoding</code> property specifying the character encoding to use for\nthe link path returned. If the <code>encoding</code> is set to <code>'buffer'</code>,\nthe link path returned will be passed as a <a href=\"buffer.html#class-buffer\" class=\"type\">&lt;Buffer&gt;</a> object.</p>"
8350 "textRaw": "`fs.realpathSync(path[, options])`",
8366 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
8389 "textRaw": "`path` {string|Buffer|URL}",
8390 "name": "path",
8412 "textRaw": "`fs.realpathSync.native(path[, options])`",
8430 "textRaw": "`path` {string|Buffer|URL}",
8431 "name": "path",
8450 "desc": "<p>Synchronous <a href=\"http://man7.org/linux/man-pages/man3/realpath.3.html\"><code>realpath(3)</code></a>.</p>\n<p>Only paths that can be converted to UTF8 strings are supported.</p>\n<p>The optional <code>options</code> argument can be a string specifying an encoding, or an\nobject with an <code>encoding</code> property specifying the character encoding to use for\nthe path returned. If the <code>encoding</code> is set to <code>'buffer'</code>,\nthe path returned will be passed as a <a href=\"buffer.html#class-buffer\" class=\"type\">&lt;Buffer&gt;</a> object.</p>\n<p>On Linux, when Node.js is linked against musl libc, the procfs file system must\nbe mounted on <code>/proc</code> in order for this function to work. Glibc does not have\nthis restriction.</p>"
8487 "textRaw": "`fs.rmdirSync(path[, options])`",
8498 "description": "Using `fs.rmdirSync(path, { recursive: true })` on a `path` that is a file is no longer permitted and results in an `ENOENT` error on Windows and an `ENOTDIR` error on POSIX."
8503 "description": "Using `fs.rmdirSync(path, { recursive: true })` on a `path` that does not exist is no longer permitted and results in a `ENOENT` error."
8531 "description": "The `path` parameters can be a WHATWG `URL` object using `file:` protocol."
8539 "textRaw": "`path` {string|Buffer|URL}",
8540 "name": "path",
8577 "textRaw": "`fs.rmSync(path[, options])`",
8591 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
8599 "textRaw": "`path` {string|Buffer|URL}",
8600 "name": "path",
8609 "textRaw": "`force` {boolean} When `true`, exceptions will be ignored if `path` does not exist. **Default:** `false`.",
8613 "desc": "When `true`, exceptions will be ignored if `path` does not exist."
8644 "textRaw": "`fs.statSync(path[, options])`",
8668 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
8681 "textRaw": "`path` {string|Buffer|URL}",
8682 "name": "path",
8709 "desc": "<p>Retrieves the <a href=\"fs.html#class-fsstats\" class=\"type\">&lt;fs.Stats&gt;</a> for the path.</p>"
8712 "textRaw": "`fs.statfsSync(path[, options])`",
8730 "textRaw": "`path` {string|Buffer|URL}",
8731 "name": "path",
8751 "desc": "<p>Synchronous <a href=\"http://man7.org/linux/man-pages/man2/statfs.2.html\"><code>statfs(2)</code></a>. Returns information about the mounted file system which\ncontains <code>path</code>.</p>\n<p>In case of an error, the <code>err.code</code> will be one of <a href=\"errors.html#common-system-errors\">Common System Errors</a>.</p>"
8754 "textRaw": "`fs.symlinkSync(target, path[, type])`",
8770 "description": "The `target` and `path` parameters can be WHATWG `URL` objects using `file:` protocol. Support is currently still *experimental*."
8783 "textRaw": "`path` {string|Buffer|URL}",
8784 "name": "path",
8796 "desc": "<p>Returns <code>undefined</code>.</p>\n<p>For detailed information, see the documentation of the asynchronous version of\nthis API: <a href=\"#fssymlinktarget-path-type-callback\"><code>fs.symlink()</code></a>.</p>"
8799 "textRaw": "`fs.truncateSync(path[, len])`",
8812 "textRaw": "`path` {string|Buffer|URL}",
8813 "name": "path",
8828 "textRaw": "`fs.unlinkSync(path)`",
8839 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
8847 "textRaw": "`path` {string|Buffer|URL}",
8848 "name": "path",
8857 "textRaw": "`fs.utimesSync(path, atime, mtime)`",
8873 "description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol."
8886 "textRaw": "`path` {string|Buffer|URL}",
8887 "name": "path",
9422 "textRaw": "`path` {string}",
9424 "name": "path",
9431 "desc": "<p>The read-only path of this directory as was provided to <a href=\"#fsopendirpath-options-callback\"><code>fs.opendir()</code></a>,\n<a href=\"#fsopendirsyncpath-options\"><code>fs.opendirSync()</code></a>, or <a href=\"#fspromisesopendirpath-options\"><code>fsPromises.opendir()</code></a>.</p>"
9627 "desc": "<p>The path to the parent directory of the file this <a href=\"fs.html#class-fsdirent\" class=\"type\">&lt;fs.Dirent&gt;</a> object refers to.</p>"
9630 "textRaw": "`path` {string}",
9632 "name": "path",
9644 "desc": "<p>The base path that this <a href=\"fs.html#class-fsdirent\" class=\"type\">&lt;fs.Dirent&gt;</a> object refers to.</p>"
9919 "textRaw": "`path` {string|Buffer}",
9921 "name": "path",
9928 "desc": "<p>The path to the file the stream is reading from as specified in the first\nargument to <code>fs.createReadStream()</code>. If <code>path</code> is passed as a string, then\n<code>readStream.path</code> will be a string. If <code>path</code> is passed as a <a href=\"buffer.html#class-buffer\" class=\"type\">&lt;Buffer&gt;</a>, then\n<code>readStream.path</code> will be a <a href=\"buffer.html#class-buffer\" class=\"type\">&lt;Buffer&gt;</a>. If <code>fd</code> is specified, then\n<code>readStream.path</code> will be <code>undefined</code>.</p>"
10027 "desc": "<p>Returns <code>true</code> if the <a href=\"fs.html#class-fsstats\" class=\"type\">&lt;fs.Stats&gt;</a> object describes a file system directory.</p>\n<p>If the <a href=\"fs.html#class-fsstats\" class=\"type\">&lt;fs.Stats&gt;</a> object was obtained from <a href=\"#fslstatpath-options-callback\"><code>fs.lstat()</code></a>, this method will\nalways return <code>false</code>. This is because <a href=\"#fslstatpath-options-callback\"><code>fs.lstat()</code></a> returns information\nabout a symbolic link itself and not the path it resolves to.</p>"
10504 "textRaw": "`writeStream.path`",
10505 "name": "path",
10512 "desc": "<p>The path to the file the stream is writing to as specified in the first\nargument to <a href=\"#fscreatewritestreampath-options\"><code>fs.createWriteStream()</code></a>. If <code>path</code> is passed as a string, then\n<code>writeStream.path</code> will be a string. If <code>path</code> is passed as a <a href=\"buffer.html#class-buffer\" class=\"type\">&lt;Buffer&gt;</a>, then\n<code>writeStream.path</code> will be a <a href=\"buffer.html#class-buffer\" class=\"type\">&lt;Buffer&gt;</a>.</p>"
10571 "desc": "<p>The following constants are exported by <code>fs.constants</code> and <code>fsPromises.constants</code>.</p>\n<p>Not every constant will be available on every operating system;\nthis is especially important for Windows, where many of the POSIX specific\ndefinitions are not available.\nFor portable applications it is recommended to check for their presence\nbefore use.</p>\n<p>To use more than one constant, use the bitwise OR <code>|</code> operator.</p>\n<p>Example:</p>\n<pre><code class=\"language-mjs\">import { open, constants } from 'node:fs';\n\nconst {\n O_RDWR,\n O_CREAT,\n O_EXCL,\n} = constants;\n\nopen('/path/to/my/file', O_RDWR | O_CREAT | O_EXCL, (err, fd) => {\n // ...\n});\n</code></pre>",
10583 "desc": "<p>The following constants are meant for use with <a href=\"#fscopyfilesrc-dest-mode-callback\"><code>fs.copyFile()</code></a>.</p>\n<table>\n <tr>\n <th>Constant</th>\n <th>Description</th>\n </tr>\n <tr>\n <td><code>COPYFILE_EXCL</code></td>\n <td>If present, the copy operation will fail with an error if the\n destination path already exists.</td>\n </tr>\n <tr>\n <td><code>COPYFILE_FICLONE</code></td>\n <td>If present, the copy operation will attempt to create a\n copy-on-write reflink. If the underlying platform does not support\n copy-on-write, then a fallback copy mechanism is used.</td>\n </tr>\n <tr>\n <td><code>COPYFILE_FICLONE_FORCE</code></td>\n <td>If present, the copy operation will attempt to create a\n copy-on-write reflink. If the underlying platform does not support\n copy-on-write, then the operation will fail with an error.</td>\n </tr>\n</table>\n<p>The definitions are also available on Windows.</p>",
10590 "desc": "<p>The following constants are meant for use with <code>fs.open()</code>.</p>\n<table>\n <tr>\n <th>Constant</th>\n <th>Description</th>\n </tr>\n <tr>\n <td><code>O_RDONLY</code></td>\n <td>Flag indicating to open a file for read-only access.</td>\n </tr>\n <tr>\n <td><code>O_WRONLY</code></td>\n <td>Flag indicating to open a file for write-only access.</td>\n </tr>\n <tr>\n <td><code>O_RDWR</code></td>\n <td>Flag indicating to open a file for read-write access.</td>\n </tr>\n <tr>\n <td><code>O_CREAT</code></td>\n <td>Flag indicating to create the file if it does not already exist.</td>\n </tr>\n <tr>\n <td><code>O_EXCL</code></td>\n <td>Flag indicating that opening a file should fail if the\n <code>O_CREAT</code> flag is set and the file already exists.</td>\n </tr>\n <tr>\n <td><code>O_NOCTTY</code></td>\n <td>Flag indicating that if path identifies a terminal device, opening the\n path shall not cause that terminal to become the controlling terminal for\n the process (if the process does not already have one).</td>\n </tr>\n <tr>\n <td><code>O_TRUNC</code></td>\n <td>Flag indicating that if the file exists and is a regular file, and the\n file is opened successfully for write access, its length shall be truncated\n to zero.</td>\n </tr>\n <tr>\n <td><code>O_APPEND</code></td>\n <td>Flag indicating that data will be appended to the end of the file.</td>\n </tr>\n <tr>\n <td><code>O_DIRECTORY</code></td>\n <td>Flag indicating that the open should fail if the path is not a\n directory.</td>\n </tr>\n <tr>\n <td><code>O_NOATIME</code></td>\n <td>Flag indicating reading accesses to the file system will no longer\n result in an update to the <code>atime</code> information associated with\n the file. This flag is available on Linux operating systems only.</td>\n </tr>\n <tr>\n <td><code>O_NOFOLLOW</code></td>\n <td>Flag indicating that the open should fail if the path is a symbolic\n link.</td>\n </tr>\n <tr>\n <td><code>O_SYNC</code></td>\n <td>Flag indicating that the file is opened for synchronized I/O with write\n operations waiting for file integrity.</td>\n </tr>\n <tr>\n <td><code>O_DSYNC</code></td>\n <td>Flag indicating that the file is opened for synchronized I/O with write\n operations waiting for data integrity.</td>\n </tr>\n <tr>\n <td><code>O_SYMLINK</code></td>\n <td>Flag indicating to open the symbolic link itself rather than the\n resource it is pointing to.</td>\n </tr>\n <tr>\n <td><code>O_DIRECT</code></td>\n <td>When set, an attempt will be made to minimize caching effects of file\n I/O.</td>\n </tr>\n <tr>\n <td><code>O_NONBLOCK</code></td>\n <td>Flag indicating to open the file in nonblocking mode when possible.</td>\n </tr>\n <tr>\n <td><code>UV_FS_O_FILEMAP</code></td>\n <td>When set, a memory file mapping is used to access the file. This flag\n is available on Windows operating systems only. On other operating systems,\n this flag is ignored.</td>\n </tr>\n</table>\n<p>On Windows, only <code>O_APPEND</code>, <code>O_CREAT</code>, <code>O_EXCL</code>, <code>O_RDONLY</code>, <code>O_RDWR</code>,\n<code>O_TRUNC</code>, <code>O_WRONLY</code>, and <code>UV_FS_O_FILEMAP</code> are available.</p>",
10637 "desc": "<p>String paths are interpreted as UTF-8 character sequences identifying\nthe absolute or relative filename. Relative paths will be resolved relative\nto the current working directory as determined by calling <code>process.cwd()</code>.</p>\n<p>Example using an absolute path on POSIX:</p>\n<pre><code class=\"language-mjs\">import { open } from 'node:fs/promises';\n\nlet fd;\ntry {\n fd = await open('/open/some/file.txt', 'r');\n // Do something with the file\n} finally {\n await fd?.close();\n}\n</code></pre>\n<p>Example using a relative path on POSIX (relative to <code>process.cwd()</code>):</p>\n<pre><code class=\"language-mjs\">import { open } from 'node:fs/promises';\n\nlet fd;\ntry {\n fd = await open('file.txt', 'r');\n // Do something with the file\n} finally {\n await fd?.close();\n}\n</code></pre>",
10650 "desc": "<p>For most <code>node:fs</code> module functions, the <code>path</code> or <code>filename</code> argument may be\npassed as a <a href=\"url.html#the-whatwg-url-api\" class=\"type\">&lt;URL&gt;</a> object using the <code>file:</code> protocol.</p>\n<pre><code class=\"language-mjs\">import { readFileSync } from 'node:fs';\n\nreadFileSync(new URL('file:///tmp/hello'));\n</code></pre>\n<p><code>file:</code> URLs are always absolute paths.</p>",
10655 "desc": "<p>On Windows, <code>file:</code> <a href=\"url.html#the-whatwg-url-api\" class=\"type\">&lt;URL&gt;</a>s with a host name convert to UNC paths, while <code>file:</code>\n<a href=\"url.html#the-whatwg-url-api\" class=\"type\">&lt;URL&gt;</a>s with drive letters convert to local absolute paths. <code>file:</code> <a href=\"url.html#the-whatwg-url-api\" class=\"type\">&lt;URL&gt;</a>s\nwith no host name and no drive letter will result in an error:</p>\n<pre><code class=\"language-mjs\">import { readFileSync } from 'node:fs';\n// On Windows :\n\n// - WHATWG file URLs with hostname convert to UNC path\n// file://hostname/p/a/t/h/file => \\\\hostname\\p\\a\\t\\h\\file\nreadFileSync(new URL('file://hostname/p/a/t/h/file'));\n\n// - WHATWG file URLs with drive letters convert to absolute path\n// file:///C:/tmp/hello => C:\\tmp\\hello\nreadFileSync(new URL('file:///C:/tmp/hello'));\n\n// - WHATWG file URLs without hostname must have a drive letters\nreadFileSync(new URL('file:///notdriveletter/p/a/t/h/file'));\nreadFileSync(new URL('file:///c/p/a/t/h/file'));\n// TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must be absolute\n</code></pre>\n<p><code>file:</code> <a href=\"url.html#the-whatwg-url-api\" class=\"type\">&lt;URL&gt;</a>s with drive letters must use <code>:</code> as a separator just after\nthe drive letter. Using another separator will result in an error.</p>\n<p>On all other platforms, <code>file:</code> <a href=\"url.html#the-whatwg-url-api\" class=\"type\">&lt;URL&gt;</a>s with a host name are unsupported and\nwill result in an error:</p>\n<pre><code class=\"language-mjs\">import { readFileSync } from 'node:fs';\n// On other platforms:\n\n// - WHATWG file URLs with hostname are unsupported\n// file://hostname/p/a/t/h/file => throw!\nreadFileSync(new URL('file://hostname/p/a/t/h/file'));\n// TypeError [ERR_INVALID_FILE_URL_PATH]: must be absolute\n\n// - WHATWG file URLs convert to absolute path\n// file:///tmp/hello => /tmp/hello\nreadFileSync(new URL('file:///tmp/hello'));\n</code></pre>\n<p>A <code>file:</code> <a href=\"url.html#the-whatwg-url-api\" class=\"type\">&lt;URL&gt;</a> having encoded slash characters will result in an error on all\nplatforms:</p>\n<pre><code class=\"language-mjs\">import { readFileSync } from 'node:fs';\n\n// On Windows\nreadFileSync(new URL('file:///C:/p/a/t/h/%2F'));\nreadFileSync(new URL('file:///C:/p/a/t/h/%2f'));\n/* TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must not include encoded\n\\ or / characters */\n\n// On POSIX\nreadFileSync(new URL('file:///p/a/t/h/%2F'));\nreadFileSync(new URL('file:///p/a/t/h/%2f'));\n/* TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must not include encoded\n/ characters */\n</code></pre>\n<p>On Windows, <code>file:</code> <a href=\"url.html#the-whatwg-url-api\" class=\"type\">&lt;URL&gt;</a>s having encoded backslash will result in an error:</p>\n<pre><code class=\"language-mjs\">import { readFileSync } from 'node:fs';\n\n// On Windows\nreadFileSync(new URL('file:///C:/path/%5C'));\nreadFileSync(new URL('file:///C:/path/%5c'));\n/* TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must not include encoded\n\\ or / characters */\n</code></pre>",
10666 "desc": "<p>Paths specified using a <a href=\"buffer.html#class-buffer\" class=\"type\">&lt;Buffer&gt;</a> are useful primarily on certain POSIX\noperating systems that treat file paths as opaque byte sequences. On such\nsystems, it is possible for a single file path to contain sub-sequences that\nuse multiple character encodings. As with string paths, <a href=\"buffer.html#class-buffer\" class=\"type\">&lt;Buffer&gt;</a> paths may\nbe relative or absolute:</p>\n<p>Example using an absolute path on POSIX:</p>\n<pre><code class=\"language-mjs\">import { open } from 'node:fs/promises';\nimport { Buffer } from 'node:buffer';\n\nlet fd;\ntry {\n fd = await open(Buffer.from('/open/some/file.txt'), 'r');\n // Do something with the file\n} finally {\n await fd?.close();\n}\n</code></pre>",
10673 "desc": "<p>On Windows, Node.js follows the concept of per-drive working directory. This\nbehavior can be observed when using a drive path without a backslash. For\nexample <code>fs.readdirSync('C:\\\\')</code> can potentially return a different result than\n<code>fs.readdirSync('C:')</code>. For more information, see\n<a href=\"https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#fully-qualified-vs-relative-paths\">this MSDN page</a>.</p>",
10698 "desc": "<p>The following flags are available wherever the <code>flag</code> option takes a\nstring.</p>\n<ul>\n<li>\n<p><code>'a'</code>: Open file for appending.\nThe file is created if it does not exist.</p>\n</li>\n<li>\n<p><code>'ax'</code>: Like <code>'a'</code> but fails if the path exists.</p>\n</li>\n<li>\n<p><code>'a+'</code>: Open file for reading and appending.\nThe file is created if it does not exist.</p>\n</li>\n<li>\n<p><code>'ax+'</code>: Like <code>'a+'</code> but fails if the path exists.</p>\n</li>\n<li>\n<p><code>'as'</code>: Open file for appending in synchronous mode.\nThe file is created if it does not exist.</p>\n</li>\n<li>\n<p><code>'as+'</code>: Open file for reading and appending in synchronous mode.\nThe file is created if it does not exist.</p>\n</li>\n<li>\n<p><code>'r'</code>: Open file for reading.\nAn exception occurs if the file does not exist.</p>\n</li>\n<li>\n<p><code>'rs'</code>: Open file for reading in synchronous mode.\nAn exception occurs if the file does not exist.</p>\n</li>\n<li>\n<p><code>'r+'</code>: Open file for reading and writing.\nAn exception occurs if the file does not exist.</p>\n</li>\n<li>\n<p><code>'rs+'</code>: Open file for reading and writing in synchronous mode. Instructs\nthe operating system to bypass the local file system cache.</p>\n<p>This is primarily useful for opening files on NFS mounts as it allows\nskipping the potentially stale local cache. It has a very real impact on\nI/O performance so using this flag is not recommended unless it is needed.</p>\n<p>This doesn't turn <code>fs.open()</code> or <code>fsPromises.open()</code> into a synchronous\nblocking call. If synchronous operation is desired, something like\n<code>fs.openSync()</code> should be used.</p>\n</li>\n<li>\n<p><code>'w'</code>: Open file for writing.\nThe file is created (if it does not exist) or truncated (if it exists).</p>\n</li>\n<li>\n<p><code>'wx'</code>: Like <code>'w'</code> but fails if the path exists.</p>\n</li>\n<li>\n<p><code>'w+'</code>: Open file for reading and writing.\nThe file is created (if it does not exist) or truncated (if it exists).</p>\n</li>\n<li>\n<p><code>'wx+'</code>: Like <code>'w+'</code> but fails if the path exists.</p>\n</li>\n</ul>\n<p><code>flag</code> can also be a number as documented by <a href=\"http://man7.org/linux/man-pages/man2/open.2.html\"><code>open(2)</code></a>; commonly used constants\nare available from <code>fs.constants</code>. On Windows, flags are translated to\ntheir equivalent ones where applicable, e.g. <code>O_WRONLY</code> to <code>FILE_GENERIC_WRITE</code>,\nor <code>O_EXCL|O_CREAT</code> to <code>CREATE_NEW</code>, as accepted by <code>CreateFileW</code>.</p>\n<p>The exclusive flag <code>'x'</code> (<code>O_EXCL</code> flag in <a href=\"http://man7.org/linux/man-pages/man2/open.2.html\"><code>open(2)</code></a>) causes the operation to\nreturn an error if the path already exists. On POSIX, if the path is a symbolic\nlink, using <code>O_EXCL</code> returns an error even if the link is to a path that does\nnot exist. The exclusive flag might not work with network file systems.</p>\n<p>On Linux, positional writes don't work when the file is opened in append mode.\nThe kernel ignores the position argument and always appends the data to\nthe end of the file.</p>\n<p>Modifying a file rather than replacing it may require the <code>flag</code> option to be\nset to <code>'r+'</code> rather than the default <code>'w'</code>.</p>\n<p>The behavior of some flags are platform-specific. As such, opening a directory\non macOS and Linux with the <code>'a+'</code> flag, as in the example below, will return an\nerror. In contrast, on Windows and FreeBSD, a file descriptor or a <code>FileHandle</code>\nwill be returned.</p>\n<pre><code class=\"language-js\">// macOS and Linux\nfs.open('&#x3C;directory>', 'a+', (err, fd) => {\n // => [Error: EISDIR: illegal operation on a directory, open &#x3C;directory>]\n});\n\n// Windows and FreeBSD\nfs.open('&#x3C;directory>', 'a+', (err, fd) => {\n // => null, &#x3C;fd>\n});\n</code></pre>\n<p>On Windows, opening an existing hidden file using the <code>'w'</code> flag (either\nthrough <code>fs.open()</code>, <code>fs.writeFile()</code>, or <code>fsPromises.open()</code>) will fail with\n<code>EPERM</code>. Existing hidden files can be opened for writing with the <code>'r+'</code> flag.</p>\n<p>A call to <code>fs.ftruncate()</code> or <code>filehandle.truncate()</code> can be used to reset\nthe file contents.</p>",