Protected
Optional
_bufferProtected
_positionProtected
closedWhether the file is open or closed
Protected
contextProtected
dirtyWhether the file has changes which have not been written to the FS
Readonly
fdReadonly
flagThe flag the handle was opened with
Protected
Readonly
fsThe internal FS associated with the handle
Readonly
inodeStats for the handle
Readonly
internalThe path relative to the FileSystem
's root
Readonly
pathThe path relative to the context's root
Get the current file position.
We emulate the following bug mentioned in the Node documentation:
On Linux, positional writes don't work when the file is opened in append mode. The kernel ignores the position argument and always appends the data to the end of the file.
The current file position.
Protected
_readRead data from the file.
The buffer that the data will be written to.
The offset within the buffer where writing will start.
An integer specifying the number of bytes to read.
An integer specifying where to begin reading from in the file. If position is unset, data will be read from the current file position.
Protected
_writeWrite buffer to the file.
Uint8Array containing the data to write to the file.
Offset in the buffer to start reading data from.
The amount of bytes to write to the file.
Offset from the beginning of the file where this data should be written. If position is null, the data will be written at the current position.
Asynchronously append data to a file, creating the file if it does not exist. The underlying file will not be closed automatically.
The FileHandle
must have been opened for appending.
The data to write. If something other than a Buffer
or Uint8Array
is provided, the value is coerced to a string.
Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
encoding
defaults to 'utf8'
.mode
defaults to 0o666
.flag
defaults to 'a'
.Asynchronous fchmod(2) - Change permissions of a file.
A file mode. If a string is passed, it is parsed as an octal integer.
Asynchronous fchown(2) - Change ownership of a file.
Asynchronous close(2) - close a FileHandle
.
Creates a stream for reading from the file.
Options for the readable stream
Creates a stream for writing to the file.
Options for the writeable stream.
Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.
Protected
disposeCleans up. This will not sync the file data to the FS
Optional
force: booleanAsynchronously reads data from the file.
The FileHandle
must have been opened for reading.
The buffer that the data will be written to.
Optional
offset: numberThe offset in the buffer at which to start writing.
Optional
length: numberThe number of bytes to read.
Optional
position: null | numberThe offset from the beginning of the file from which data should be read. If null
, data will be read from the current position.
Asynchronously reads data from the file.
The FileHandle
must have been opened for reading.
Read file data using a ReadableStream
.
The handle will not be closed automatically.
Asynchronously reads the entire contents of a file. The underlying file will not be closed automatically.
The FileHandle
must have been opened for reading.
Optional
_options: { flag?: OpenMode }An object that may contain an optional flag.
If a flag is not provided, it defaults to 'r'
.
Asynchronously reads the entire contents of a file. The underlying file will not be closed automatically.
The FileHandle
must have been opened for reading.
Creates a readline Interface object that allows reading the file line by line
Optional
options: CreateReadStreamOptionsOptions for creating a read stream
A readline interface for reading the file line by line
Asynchronous readv
. Reads into multiple buffers.
An array of Uint8Array buffers.
Optional
position: numberThe position in the file where to begin reading.
The number of bytes read.
Asynchronous fstat(2) - Get file status.
Optional
opts: StatOptions & { bigint?: false }Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
Asynchronous ftruncate(2) - Truncate a file to a specified length.
If not specified, defaults to 0
.
Asynchronously change file timestamps of the file.
The last access time. If a string is provided, it will be coerced to number.
The last modified time. If a string is provided, it will be coerced to number.
Internal
Not part of the Node.js API!
Write file data using a WritableStream
.
The handle will not be closed automatically.
Asynchronously writes string
to the file.
The FileHandle
must have been opened for writing.
It is unsafe to call write()
multiple times on the same file without waiting for the Promise
to be resolved (or rejected). For this scenario, createWriteStream
is strongly recommended.
Optional
options: null | number | { length?: number; offset?: number; position?: number }Optional
lenOrEnc: null | number | BufferEncodingOptional
position: null | numberAsynchronously writes data to a file, replacing the file if it already exists. The underlying file will not be closed automatically.
The FileHandle
must have been opened for writing.
It is unsafe to call writeFile()
multiple times on the same file without waiting for the Promise
to be resolved (or rejected).
The data to write. If something other than a Buffer
or Uint8Array
is provided, the value is coerced to a string.
Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
encoding
defaults to 'utf8'
.mode
defaults to 0o666
.flag
defaults to 'w'
.Asynchronous writev
. Writes from multiple buffers.
An array of Uint8Array buffers.
Optional
position: numberThe position in the file where to begin writing.
The number of bytes written.
Current position