Resets the stream position to the beginning of the file.
Closes the underlying Deno.FsFile. After calling close(),
isOpen returns false.
Inserts data at byte offset start, optionally replacing replace
bytes of existing content. The position is set to start + data.length
after the operation.
Because Deno.FsFile does not support in-place insertion, this method
reads the tail of the file, writes the new data at start, then writes
the tail back, and truncates if necessary.
The bytes to insert.
Byte offset at which to begin the insertion.
Number of existing bytes to overwrite. Defaults to 0.
Returns true if the stream has not yet been closed.
Returns the total size of the file in bytes.
Returns the file path this stream was opened with.
Reads up to length bytes from the current file position and advances
the position by the number of bytes actually read.
Maximum number of bytes to read.
Resolves with a ByteVector containing the bytes read.
May be shorter than length when the end of the file is reached.
Returns true if this stream was opened in read-only mode.
Moves the read/write position within the file.
Number of bytes to move relative to position.
Reference point for the seek. Defaults to Position.Beginning.
Returns the current read/write position in bytes from the start of the file.
Writes data at the current file position, extending the file if
necessary, and advances the position by data.length.
The bytes to write.
StaticopenOpens a file at path for reading and optionally writing.
Internally calls:
await Deno.open(path, { read: true, write: true, create: create ?? false })
Absolute or relative path to the file.
Optionalcreate: booleanWhen true the file is created if it does not exist.
Defaults to false.
A fully initialised DenoFileStream in read-write mode.
StaticopenOpens a file at path for reading only.
Internally calls:
await Deno.open(path, { read: true })
Absolute or relative path to the file.
A fully initialised DenoFileStream in read-only mode.
A read/write IOStream backed by a
Deno.FsFilefrom Deno's native file system API.Read-write mode (default): opens the file with
{ read: true, write: true }. All mutating operations (writeBlock,insert,removeBlock,truncate) are available.Read-only mode: opens the file with
{ read: true }only. Any attempt to call a mutating method throws anError.The constructor is private. Always use one of the async factories:
Example
Example