Common Objects
History
The common objects are shared by all of the file system API variants (promise, callback, and synchronous).
A class representing a directory stream.
Created by fs.opendir(), fs.opendirSync(), or
fsPromises.opendir().
import { opendir } from 'node:fs/promises'; try { const dir = await opendir('./'); for await (const dirent of dir) console.log(dirent.name); } catch (err) { console.error(err); }
When using the async iterator, the fs.Dir object will be automatically
closed after the iterator exits.
dir.close(): Promise
PromiseAsynchronously close the directory's underlying resource handle. Subsequent reads will result in errors.
A promise is returned that will be fulfilled after the resource has been closed.
dir.close(callback): void
Asynchronously close the directory's underlying resource handle. Subsequent reads will result in errors.
The callback will be called after the resource handle has been closed.
dir.closeSync(): void
Synchronously close the directory's underlying resource handle. Subsequent reads will result in errors.
stringThe read-only path of this directory as was provided to fs.opendir(),
fs.opendirSync(), or fsPromises.opendir().
dir.read(): Promise
Asynchronously read the next directory entry via readdir(3) as an fs.Dirent.
A promise is returned that will be fulfilled with an fs.Dirent, or null
if there are no more directory entries to read.
Directory entries returned by this function are in no particular order as provided by the operating system's underlying directory mechanisms. Entries added or removed while iterating over the directory might not be included in the iteration results.
dir.read(callback): void
Asynchronously read the next directory entry via readdir(3) as an fs.Dirent.
After the read is completed, the callback will be called with an
fs.Dirent, or null if there are no more directory entries to read.
Directory entries returned by this function are in no particular order as provided by the operating system's underlying directory mechanisms. Entries added or removed while iterating over the directory might not be included in the iteration results.
dir.readSync(): fs.Dirent | null
Synchronously read the next directory entry as an fs.Dirent. See the
POSIX readdir(3) documentation for more detail.
If there are no more directory entries to read, null will be returned.
Directory entries returned by this function are in no particular order as provided by the operating system's underlying directory mechanisms. Entries added or removed while iterating over the directory might not be included in the iteration results.
dir[Symbol.asyncIterator](): AsyncIterator
AsyncIteratorfs.DirentAsynchronously iterates over the directory until all entries have
been read. Refer to the POSIX readdir(3) documentation for more detail.
Entries returned by the async iterator are always an fs.Dirent.
The null case from dir.read() is handled internally.
See fs.Dir for an example.
Directory entries returned by this iterator are in no particular order as provided by the operating system's underlying directory mechanisms. Entries added or removed while iterating over the directory might not be included in the iteration results.
dir[Symbol.asyncDispose]
History
dir[Symbol.asyncDispose](): Promise
PromiseCalls dir.close() if the directory handle is open, and returns a promise that
fulfills when disposal is complete.
This method enables the directory to be used with await using, which
will automatically close the directory when the scope exits. For more
information, see the MDN documentation on using statements.
dir[Symbol.dispose](): void
Calls dir.closeSync() if the directory handle is open, and returns
undefined.
This method enables the directory to be used with using, which
will automatically close the directory when the scope exits. For more
information, see the MDN documentation on using statements.
A representation of a directory entry, which can be a file or a subdirectory
within the directory, as returned by reading from an fs.Dir. The
directory entry is a combination of the file name and file type pairs.
Additionally, when fs.readdir() or fs.readdirSync() is called with
the withFileTypes option set to true, the resulting array is filled with
fs.Dirent objects, rather than strings or Buffers.
When a directory is read, such as with fs.readdir() or
fs.opendir(), the file type of each entry is the type reported by the
operating system and may depend on the file system; for example, some file
systems may report a type that differs from what fs.lstat() returns.
Node.js calls fs.lstat() on such an entry only when the reported type
is unknown. Use fs.lstat() when an accurate file type is required.
dirent.isBlockDevice(): boolean
booleanReturns true if the fs.Dirent object describes a block device.
dirent.isCharacterDevice(): boolean
booleanReturns true if the fs.Dirent object describes a character device.
dirent.isDirectory(): boolean
booleanReturns true if the fs.Dirent object describes a file system
directory.
dirent.isFIFO(): boolean
booleanReturns true if the fs.Dirent object describes a first-in-first-out
(FIFO) pipe.
dirent.isFile(): boolean
booleanReturns true if the fs.Dirent object describes a regular file.
dirent.isSocket(): boolean
booleanReturns true if the fs.Dirent object describes a socket.
dirent.isSymbolicLink(): boolean
booleanReturns true if the fs.Dirent object describes a symbolic link.
The file name that this fs.Dirent object refers to. The type of this
value is determined by the options.encoding passed to fs.readdir() or
fs.readdirSync().
dirent.parentPath
History
stringThe path to the parent directory of the file this fs.Dirent object refers to.
class fs.FSWatcher extends EventEmitter
A successful call to fs.watch() method will return a new fs.FSWatcher
object.
All fs.FSWatcher objects emit a 'change' event whenever a specific watched
file is modified.
Emitted when something changes in a watched directory or file.
See more details in fs.watch().
The filename argument may not be provided depending on operating system
support. If filename is provided, it will be provided as a Buffer if
fs.watch() is called with its encoding option set to 'buffer', otherwise
filename will be a UTF-8 string.
import { watch } from 'node:fs'; // Example when handled through fs.watch() listener watch('./tmp', { encoding: 'buffer' }, (eventType, filename) => { if (filename) { console.log(filename); // Prints: <Buffer ...> } });
Emitted when the watcher stops watching for changes. The closed
fs.FSWatcher object is no longer usable in the event handler.
ErrorEmitted when an error occurs while watching the file. The errored
fs.FSWatcher object is no longer usable in the event handler.
watcher.close(): void
Stop watching for changes on the given fs.FSWatcher. Once stopped, the
fs.FSWatcher object is no longer usable.
watcher.ref(): fs.FSWatcher
fs.FSWatcherWhen called, requests that the Node.js event loop not exit so long as the
fs.FSWatcher is active. Calling watcher.ref() multiple times will have
no effect.
By default, all fs.FSWatcher objects are "ref'ed", making it normally
unnecessary to call watcher.ref() unless watcher.unref() had been
called previously.
watcher.unref(): fs.FSWatcher
fs.FSWatcherWhen called, the active fs.FSWatcher object will not require the Node.js
event loop to remain active. If there is no other activity keeping the
event loop running, the process may exit before the fs.FSWatcher object's
callback is invoked. Calling watcher.unref() multiple times will have
no effect.
class fs.StatWatcher extends EventEmitter
A successful call to fs.watchFile() method will return a new fs.StatWatcher
object.
watcher.ref(): fs.StatWatcher
fs.StatWatcherWhen called, requests that the Node.js event loop not exit so long as the
fs.StatWatcher is active. Calling watcher.ref() multiple times will have
no effect.
By default, all fs.StatWatcher objects are "ref'ed", making it normally
unnecessary to call watcher.ref() unless watcher.unref() had been
called previously.
watcher.unref(): fs.StatWatcher
fs.StatWatcherWhen called, the active fs.StatWatcher object will not require the Node.js
event loop to remain active. If there is no other activity keeping the
event loop running, the process may exit before the fs.StatWatcher object's
callback is invoked. Calling watcher.unref() multiple times will have
no effect.
class fs.ReadStream extends stream.Readable
Instances of fs.ReadStream cannot be constructed directly. They are created and
returned using the fs.createReadStream() function.
Emitted when the fs.ReadStream's underlying file descriptor has been closed.
integerfs.ReadStream.Emitted when the fs.ReadStream's file descriptor has been opened.
Emitted when the fs.ReadStream is ready to be used.
Fires immediately after 'open'.
numberThe number of bytes that have been read so far.
The path to the file the stream is reading from as specified in the first
argument to fs.createReadStream(). If path is passed as a string, then
readStream.path will be a string. If path is passed as a Buffer, then
readStream.path will be a Buffer. If fd is specified, then
readStream.path will be undefined.
booleanThis property is true if the underlying file has not been opened yet,
i.e. before the 'ready' event is emitted.
A fs.Stats object provides information about a file.
Objects returned from fs.stat(), fs.lstat(), fs.fstat(), and
their synchronous counterparts are of this type.
If bigint in the options passed to those methods is true, the numeric values
will be bigint instead of number, and the object will contain additional
nanosecond-precision properties suffixed with Ns.
Stat objects are not to be created directly using the new keyword.
Stats { dev: 2114, ino: 48064969, mode: 33188, nlink: 1, uid: 85, gid: 100, rdev: 0, size: 527, blksize: 4096, blocks: 8, atimeMs: 1318289051000.1, mtimeMs: 1318289051000.1, ctimeMs: 1318289051000.1, birthtimeMs: 1318289051000.1, // Instances of Date atime: Mon, 10 Oct 2011 23:24:11 GMT, mtime: Mon, 10 Oct 2011 23:24:11 GMT, ctime: Mon, 10 Oct 2011 23:24:11 GMT, birthtime: Mon, 10 Oct 2011 23:24:11 GMT, // Instances of Temporal.Instant atimeInstant: 2011-10-10T23:24:11.0001Z, mtimeInstant: 2011-10-10T23:24:11.0001Z, ctimeInstant: 2011-10-10T23:24:11.0001Z, birthtimeInstant: 2011-10-10T23:24:11.0001Z }
bigint version:
BigIntStats { dev: 2114n, ino: 48064969n, mode: 33188n, nlink: 1n, uid: 85n, gid: 100n, rdev: 0n, size: 527n, blksize: 4096n, blocks: 8n, atimeMs: 1318289051000n, mtimeMs: 1318289051000n, ctimeMs: 1318289051000n, birthtimeMs: 1318289051000n, atimeNs: 1318289051000000000n, mtimeNs: 1318289051000000000n, ctimeNs: 1318289051000000000n, birthtimeNs: 1318289051000000000n, // Instances of Date atime: Mon, 10 Oct 2011 23:24:11 GMT, mtime: Mon, 10 Oct 2011 23:24:11 GMT, ctime: Mon, 10 Oct 2011 23:24:11 GMT, birthtime: Mon, 10 Oct 2011 23:24:11 GMT, // Instances of Temporal.Instant atimeInstant: 2011-10-10T23:24:11Z, mtimeInstant: 2011-10-10T23:24:11Z, ctimeInstant: 2011-10-10T23:24:11Z, birthtimeInstant: 2011-10-10T23:24:11Z }
stats.isBlockDevice(): boolean
booleanReturns true if the fs.Stats object describes a block device.
stats.isCharacterDevice(): boolean
booleanReturns true if the fs.Stats object describes a character device.
stats.isDirectory(): boolean
booleanReturns true if the fs.Stats object describes a file system directory.
If the fs.Stats object was obtained from calling fs.lstat() on a
symbolic link which resolves to a directory, this method will return false.
This is because fs.lstat() returns information
about a symbolic link itself and not the path it resolves to.
stats.isFIFO(): boolean
booleanReturns true if the fs.Stats object describes a first-in-first-out (FIFO)
pipe.
stats.isFile(): boolean
booleanReturns true if the fs.Stats object describes a regular file.
stats.isSocket(): boolean
booleanReturns true if the fs.Stats object describes a socket.
stats.isSymbolicLink(): boolean
booleanReturns true if the fs.Stats object describes a symbolic link.
This method is only valid when using fs.lstat().
The numeric identifier of the device containing the file.
The file system specific "Inode" number for the file.
A bit-field describing the file type and mode.
The number of hard-links that exist for the file.
The numeric user identifier of the user that owns the file (POSIX).
The numeric group identifier of the group that owns the file (POSIX).
A numeric device identifier if the file represents a device.
The size of the file in bytes.
If the underlying file system does not support getting the size of the file,
this will be 0.
The file system block size for i/o operations.
The number of blocks allocated for this file.
The timestamp indicating the last time this file was accessed expressed in milliseconds since the POSIX Epoch.
The timestamp indicating the last time this file was modified expressed in milliseconds since the POSIX Epoch.
The timestamp indicating the last time the file status was changed expressed in milliseconds since the POSIX Epoch.
The timestamp indicating the creation time of this file expressed in milliseconds since the POSIX Epoch.
bigintOnly present when bigint: true is passed into the method that generates
the object.
The timestamp indicating the last time this file was accessed expressed in
nanoseconds since the POSIX Epoch.
bigintOnly present when bigint: true is passed into the method that generates
the object.
The timestamp indicating the last time this file was modified expressed in
nanoseconds since the POSIX Epoch.
bigintOnly present when bigint: true is passed into the method that generates
the object.
The timestamp indicating the last time the file status was changed expressed
in nanoseconds since the POSIX Epoch.
bigintOnly present when bigint: true is passed into the method that generates
the object.
The timestamp indicating the creation time of this file expressed in
nanoseconds since the POSIX Epoch.
DateThe timestamp indicating the last time this file was accessed.
DateThe timestamp indicating the last time this file was modified.
DateThe timestamp indicating the last time the file status was changed.
DateThe timestamp indicating the creation time of this file.
The atimeMs, mtimeMs, ctimeMs, birthtimeMs properties are
numeric values that hold the corresponding times in milliseconds. Their
precision is platform specific. When bigint: true is passed into the
method that generates the object, the properties will be bigints,
otherwise they will be numbers.
The atimeNs, mtimeNs, ctimeNs, birthtimeNs properties are
bigints that hold the corresponding times in nanoseconds. They are
only present when bigint: true is passed into the method that generates
the object. Their precision is platform specific.
atime, mtime, ctime, and birthtime are
Date object alternate representations of the various times. The
Date and number values are not connected. Assigning a new number value, or
mutating the Date value, will not be reflected in the corresponding alternate
representation.
The times in the stat object have the following semantics:
atime"Access Time": Time when file data last accessed. Changed by themknod(2),utimes(2), andread(2)system calls.mtime"Modified Time": Time when file data last modified. Changed by themknod(2),utimes(2), andwrite(2)system calls.ctime"Change Time": Time when file status was last changed (inode data modification). Changed by thechmod(2),chown(2),link(2),mknod(2),rename(2),unlink(2),utimes(2),read(2), andwrite(2)system calls.birthtime"Birth Time": Time of file creation. Set once when the file is created. On file systems where birthtime is not available, this field may instead hold either thectimeor1970-01-01T00:00Z(ie, Unix epoch timestamp0). This value may be greater thanatimeormtimein this case. On Darwin and other FreeBSD variants, also set if theatimeis explicitly set to an earlier value than the currentbirthtimeusing theutimes(2)system call.
Prior to Node.js 0.12, the ctime held the birthtime on Windows systems. As
of 0.12, ctime is not "creation time", and on Unix systems, it never was.
Provides information about a mounted file system.
Objects returned from fs.statfs() and its synchronous counterpart are of
this type. If bigint in the options passed to those methods is true, the
numeric values will be bigint instead of number.
StatFs { type: 1397114950, bsize: 4096, frsize: 4096, blocks: 121938943, bfree: 61058895, bavail: 61058895, files: 999, ffree: 1000000 }
bigint version:
StatFs { type: 1397114950n, bsize: 4096n, frsize: 4096n, blocks: 121938943n, bfree: 61058895n, bavail: 61058895n, files: 999n, ffree: 1000000n }
Free blocks available to unprivileged users. Multiply by statfs.bsize
to get the number of available bytes.
import { statfs } from 'node:fs/promises'; const stats = await statfs('/'); const availableBytes = stats.bsize * stats.bavail; console.log(`Available space: ${availableBytes} bytes`);
const { statfs } = require('node:fs/promises'); (async () => { const stats = await statfs('/'); const availableBytes = stats.bsize * stats.bavail; console.log(`Available space: ${availableBytes} bytes`); })();
Free blocks in file system. Multiply by statfs.bsize to get the number
of free bytes.
import { statfs } from 'node:fs/promises'; const stats = await statfs('/'); const freeBytes = stats.bsize * stats.bfree; console.log(`Free space: ${freeBytes} bytes`);
const { statfs } = require('node:fs/promises'); (async () => { const stats = await statfs('/'); const freeBytes = stats.bsize * stats.bfree; console.log(`Free space: ${freeBytes} bytes`); })();
Total data blocks in file system. Multiply by statfs.bsize to get the
total size in bytes.
import { statfs } from 'node:fs/promises'; const stats = await statfs('/'); const totalBytes = stats.bsize * stats.blocks; console.log(`Total space: ${totalBytes} bytes`);
const { statfs } = require('node:fs/promises'); (async () => { const stats = await statfs('/'); const totalBytes = stats.bsize * stats.blocks; console.log(`Total space: ${totalBytes} bytes`); })();
Optimal transfer block size in bytes.
Fundamental file system block size.
Free file nodes in file system.
Total file nodes in file system.
Type of file system. A platform-specific numeric identifier for the type of
file system. This value corresponds to the f_type field returned by
statfs(2) on POSIX systems (for example, 0xEF53 for ext4 on Linux). Its
meaning is OS-dependent and is not guaranteed to be consistent across
platforms.
An optimized UTF-8 stream writer that allows for flushing all the internal
buffering on demand. It handles EAGAIN errors correctly, allowing for
customization, for example, by dropping content if the disk is busy.
The 'close' event is emitted when the stream is fully closed.
The 'drain' event is emitted when the internal buffer has drained sufficiently
to allow continued writing.
drop
The 'drop' event is emitted when the maximal length is reached and that data
will not be written. The data that was dropped is passed as the first argument
to the event handler.
The 'error' event is emitted when an error occurs.
The 'finish' event is emitted when the stream has been ended and all data has
been flushed to the underlying file.
The 'ready' event is emitted when the stream is ready to accept writes.
The 'write' event is emitted when a write operation has completed. The number
of bytes written is passed as the first argument to the event handler.
new fs.Utf8Stream(options?): fs.Utf8Stream
Objectboolean Appends writes to dest file instead of truncating it.
Default: true.string Which type of data you can send to the write
function, supported values are 'utf8' or 'buffer'. Default:
'utf8'.string A path to a file to be written to (mode controlled by the
append option).Object An object that has the same API as the fs module, useful
for mocking, testing, or customizing the behavior of the stream.boolean Perform a fs.fsyncSync() every time a write is
completed.number The maximum length of the internal buffer. If a write
operation would cause the buffer to exceed maxLength, the data written is
dropped and a drop event is emitted with the dropped datanumber The maximum number of bytes that can be written;
Default: 16384number The minimum length of the internal buffer that is
required to be full before flushing.number Calls flush every periodicFlush milliseconds.Functionwrite(),
writeSync(), or flushSync() encounters an EAGAIN or EBUSY error.
If the return value is true the operation will be retried, otherwise it
will bubble the error. The err is the error that caused this function to
be called, writeBufferLen is the length of the buffer that was written,
and remainingBufferLen is the length of the remaining buffer that the
stream did not try to write.boolean Perform writes synchronously.fs.Utf8Stream'utf8' or 'buffer'. Default: 'utf8'.utf8Stream.destroy(): void
Close the stream immediately, without flushing the internal buffer.
utf8Stream.end(): void
Close the stream gracefully, flushing the internal buffer before closing.
utf8Stream.flush(callback): void
Writes the current buffer to the file if a write was not in progress. Do
nothing if minLength is zero or if it is already writing.
utf8Stream.flushSync(): void
Flushes the buffered data synchronously. This is a costly operation.
fs.fsyncSync() after every
write operation.maxLength, the data written is
dropped and a drop event is emitted with the dropped data.dest file exists. If true, it will create the directory if it does not
exist. Default: false.0, no
periodic flushes will be performed.utf8Stream.reopen(file): void
file:string | Buffer | URLA path to a file to be written to (mode controlled by the append option).
Reopen the file in place, useful for log rotation.
utf8Stream.write(data): boolean
When the options.contentMode is set to 'utf8' when the stream is created,
the data argument must be a string. If the contentMode is set to 'buffer',
the data argument must be a Buffer.
utf8Stream[Symbol.dispose](): void
Calls utf8Stream.destroy().
This method enables the stream to be used with using, which
will automatically destroy the stream when the scope exits. For more
information, see the MDN documentation on using statements.
class fs.WriteStream extends stream.Writable
Instances of fs.WriteStream cannot be constructed directly. They are created and
returned using the fs.createWriteStream() function.
Emitted when the fs.WriteStream's underlying file descriptor has been closed.
integerfs.WriteStream.Emitted when the fs.WriteStream's file is opened.
Emitted when the fs.WriteStream is ready to be used.
Fires immediately after 'open'.
The number of bytes written so far. Does not include data that is still queued for writing.
writeStream.close(callback?): void
Closes writeStream. Optionally accepts a
callback that will be executed once the writeStream
is closed.
The path to the file the stream is writing to as specified in the first
argument to fs.createWriteStream(). If path is passed as a string, then
writeStream.path will be a string. If path is passed as a Buffer, then
writeStream.path will be a Buffer.
booleanThis property is true if the underlying file has not been opened yet,
i.e. before the 'ready' event is emitted.
ObjectReturns an object containing commonly used constants for file system operations.
The following constants are exported by fs.constants and fsPromises.constants.
Not every constant will be available on every operating system; this is especially important for Windows, where many of the POSIX specific definitions are not available. For portable applications it is recommended to check for their presence before use.
To use more than one constant, use the bitwise OR | operator.
Example:
import { open, constants } from 'node:fs'; const { O_RDWR, O_CREAT, O_EXCL, } = constants; open('/path/to/my/file', O_RDWR | O_CREAT | O_EXCL, (err, fd) => { // ... });
The following constants are meant for use as the mode parameter passed to
fsPromises.access(), fs.access(), and fs.accessSync().
| Constant | Description |
|---|---|
F_OK |
Flag indicating that the file is visible to the calling process.
This is useful for determining if a file exists, but says nothing
about rwx permissions. Default if no mode is specified. |
R_OK |
Flag indicating that the file can be read by the calling process. |
W_OK |
Flag indicating that the file can be written by the calling process. |
X_OK |
Flag indicating that the file can be executed by the calling
process. This has no effect on Windows
(will behave like fs.constants.F_OK). |
The definitions are also available on Windows.
The following constants are meant for use with fs.copyFile().
| Constant | Description |
|---|---|
COPYFILE_EXCL |
If present, the copy operation will fail with an error if the destination path already exists. |
COPYFILE_FICLONE |
If present, the copy operation will attempt to create a copy-on-write reflink. If the underlying platform does not support copy-on-write, then a fallback copy mechanism is used. |
COPYFILE_FICLONE_FORCE |
If present, the copy operation will attempt to create a copy-on-write reflink. If the underlying platform does not support copy-on-write, then the operation will fail with an error. |
The definitions are also available on Windows.
The following constants are meant for use with fs.open().
| Constant | Description |
|---|---|
O_RDONLY |
Flag indicating to open a file for read-only access. |
O_WRONLY |
Flag indicating to open a file for write-only access. |
O_RDWR |
Flag indicating to open a file for read-write access. |
O_CREAT |
Flag indicating to create the file if it does not already exist. |
O_EXCL |
Flag indicating that opening a file should fail if the
O_CREAT flag is set and the file already exists. |
O_NOCTTY |
Flag indicating that if path identifies a terminal device, opening the path shall not cause that terminal to become the controlling terminal for the process (if the process does not already have one). |
O_TRUNC |
Flag indicating that if the file exists and is a regular file, and the file is opened successfully for write access, its length shall be truncated to zero. |
O_APPEND |
Flag indicating that data will be appended to the end of the file. |
O_DIRECTORY |
Flag indicating that the open should fail if the path is not a directory. |
O_NOATIME |
Flag indicating reading accesses to the file system will no longer
result in an update to the atime information associated with
the file. This flag is available on Linux operating systems only. |
O_NOFOLLOW |
Flag indicating that the open should fail if the path is a symbolic link. |
O_SYNC |
Flag indicating that the file is opened for synchronized I/O with write
operations waiting for file integrity. On Windows, this maps to
FILE_FLAG_WRITE_THROUGH. |
O_DSYNC |
Flag indicating that the file is opened for synchronized I/O with write
operations waiting for data integrity. On Windows, this maps to
FILE_FLAG_WRITE_THROUGH. |
O_SYMLINK |
Flag indicating to open the symbolic link itself rather than the resource it is pointing to. |
O_DIRECT |
When set, an attempt will be made to minimize caching effects of file
I/O. On Windows, this maps to FILE_FLAG_NO_BUFFERING. |
O_NONBLOCK |
Flag indicating to open the file in nonblocking mode when possible. |
UV_FS_O_FILEMAP |
When set, a memory file mapping is used to access the file. This flag is available on Windows operating systems only. On other operating systems, this flag is ignored. |
UV_FS_O_TEMPORARY |
When set, the file is deleted automatically when the last handle to it is closed. This flag is available on Windows operating systems only. On other operating systems, this flag is ignored. |
UV_FS_O_SHORT_LIVED |
Hint that the file is short-lived, so the system avoids flushing it to disk when possible. This flag is available on Windows operating systems only. On other operating systems, this flag is ignored. |
UV_FS_O_SEQUENTIAL |
Hint that the file is accessed sequentially from beginning to end, to optimize caching. This flag is available on Windows operating systems only. On other operating systems, this flag is ignored. |
UV_FS_O_RANDOM |
Hint that the file is accessed randomly, to optimize caching. This flag is available on Windows operating systems only. On other operating systems, this flag is ignored. |
On Windows, only O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR,
O_TRUNC, O_WRONLY, UV_FS_O_FILEMAP, UV_FS_O_TEMPORARY,
UV_FS_O_SHORT_LIVED, UV_FS_O_SEQUENTIAL, and UV_FS_O_RANDOM are
available.
The following constants are meant for use with the fs.Stats object's
mode property for determining a file's type.
| Constant | Description |
|---|---|
S_IFMT |
Bit mask used to extract the file type code. |
S_IFREG |
File type constant for a regular file. |
S_IFDIR |
File type constant for a directory. |
S_IFCHR |
File type constant for a character-oriented device file. |
S_IFBLK |
File type constant for a block-oriented device file. |
S_IFIFO |
File type constant for a FIFO/pipe. |
S_IFLNK |
File type constant for a symbolic link. |
S_IFSOCK |
File type constant for a socket. |
On Windows, only S_IFCHR, S_IFDIR, S_IFLNK, S_IFMT, and S_IFREG,
are available.
The following constants are meant for use with the fs.Stats object's
mode property for determining the access permissions for a file.
| Constant | Description |
|---|---|
S_IRWXU |
File mode indicating readable, writable, and executable by owner. |
S_IRUSR |
File mode indicating readable by owner. |
S_IWUSR |
File mode indicating writable by owner. |
S_IXUSR |
File mode indicating executable by owner. |
S_IRWXG |
File mode indicating readable, writable, and executable by group. |
S_IRGRP |
File mode indicating readable by group. |
S_IWGRP |
File mode indicating writable by group. |
S_IXGRP |
File mode indicating executable by group. |
S_IRWXO |
File mode indicating readable, writable, and executable by others. |
S_IROTH |
File mode indicating readable by others. |
S_IWOTH |
File mode indicating writable by others. |
S_IXOTH |
File mode indicating executable by others. |
On Windows, only S_IRUSR and S_IWUSR are available.