Handle
Defined in: src/vfs/file.ts:26
Internal
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Handle(
context,path,internalPath,flag,vnode):Handle
Defined in: src/vfs/file.ts:91
Creates a file handle for the vnode.
Parameters
Section titled “Parameters”context
Section titled “context”unknown
string
internalPath
Section titled “internalPath”string
number
VNode
Returns
Section titled “Returns”Handle
Properties
Section titled “Properties”_position
Section titled “_position”
protected_position:number=0
Defined in: src/vfs/file.ts:30
Current position
closed
Section titled “closed”
protectedclosed:boolean=false
Defined in: src/vfs/file.ts:72
Whether the file is open or closed
context
Section titled “context”
readonlycontext:unknown
Defined in: src/vfs/file.ts:92
readonlyflag:number
Defined in: src/vfs/file.ts:95
internalPath
Section titled “internalPath”
readonlyinternalPath:string
Defined in: src/vfs/file.ts:94
readonlypath:string
Defined in: src/vfs/file.ts:93
protectedrefs:number=1
Defined in: src/vfs/file.ts:75
How many descriptors refer to this open file
readonlyvnode:VNode
Defined in: src/vfs/file.ts:96
Accessors
Section titled “Accessors”_isSync
Section titled “_isSync”Get Signature
Section titled “Get Signature”get
protected_isSync():boolean
Defined in: src/vfs/file.ts:99
Returns
Section titled “Returns”boolean
Get Signature
Section titled “Get Signature”get
protecteddirty():boolean
Defined in: src/vfs/file.ts:65
Whether the file has changes which have not been written to the FS
Returns
Section titled “Returns”boolean
Get Signature
Section titled “Get Signature”get fs():
FileSystem
Defined in: src/vfs/file.ts:58
Returns
Section titled “Returns”Get Signature
Section titled “Get Signature”get inode():
InodeLike
Defined in: src/vfs/file.ts:53
The inode for the file. This is shared between all handles for the file via the vnode.
Returns
Section titled “Returns”isClosed
Section titled “isClosed”Get Signature
Section titled “Get Signature”get isClosed():
boolean
Defined in: src/vfs/file.ts:84
Returns
Section titled “Returns”boolean
position
Section titled “position”Get Signature
Section titled “Get Signature”get position():
number
Defined in: src/vfs/file.ts:41
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.
Returns
Section titled “Returns”number
The current file position.
Set Signature
Section titled “Set Signature”set position(
value):void
Defined in: src/vfs/file.ts:45
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
Methods
Section titled “Methods”[asyncDispose]()
Section titled “[asyncDispose]()”[asyncDispose]():
Promise<void>
Defined in: src/vfs/file.ts:245
Returns
Section titled “Returns”Promise<void>
[dispose]()
Section titled “[dispose]()”[dispose]():
void
Defined in: src/vfs/file.ts:103
Returns
Section titled “Returns”void
chmod()
Section titled “chmod()”chmod(
mode):Promise<void>
Defined in: src/vfs/file.ts:369
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”Promise<void>
chmodSync()
Section titled “chmodSync()”chmodSync(
mode):void
Defined in: src/vfs/file.ts:216
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
chown()
Section titled “chown()”chown(
uid,gid):Promise<void>
Defined in: src/vfs/file.ts:377
Parameters
Section titled “Parameters”number
number
Returns
Section titled “Returns”Promise<void>
chownSync()
Section titled “chownSync()”chownSync(
uid,gid):void
Defined in: src/vfs/file.ts:224
Parameters
Section titled “Parameters”number
number
Returns
Section titled “Returns”void
close()
Section titled “close()”close():
Promise<void>
Defined in: src/vfs/file.ts:265
Returns
Section titled “Returns”Promise<void>
closeSync()
Section titled “closeSync()”closeSync():
void
Defined in: src/vfs/file.ts:123
Returns
Section titled “Returns”void
datasync()
Section titled “datasync()”datasync():
Promise<void>
Defined in: src/vfs/file.ts:261
Default implementation maps to sync.
Returns
Section titled “Returns”Promise<void>
datasyncSync()
Section titled “datasyncSync()”datasyncSync():
void
Defined in: src/vfs/file.ts:119
Default implementation maps to syncSync.
Returns
Section titled “Returns”void
dispose()
Section titled “dispose()”
protecteddispose(force?):void
Defined in: src/vfs/file.ts:275
Cleans up. This will not sync the file data to the FS
Parameters
Section titled “Parameters”force?
Section titled “force?”boolean
Returns
Section titled “Returns”void
disposeSync()
Section titled “disposeSync()”
protecteddisposeSync(force?):void
Defined in: src/vfs/file.ts:133
Cleans up. This will not sync the file data to the FS
Parameters
Section titled “Parameters”force?
Section titled “force?”boolean
Returns
Section titled “Returns”void
read()
Section titled “read()”read(
buffer,offset?,length?,position?):Promise<number>
Defined in: src/vfs/file.ts:342
Read data from the file.
Parameters
Section titled “Parameters”buffer
Section titled “buffer”ArrayBufferView
The buffer that the data will be written to.
offset?
Section titled “offset?”number = 0
The offset within the buffer where writing will start.
length?
Section titled “length?”number = ...
An integer specifying the number of bytes to read.
position?
Section titled “position?”number = ...
An integer specifying where to begin reading from in the file. If position is null, data will be read from the current file position.
Returns
Section titled “Returns”Promise<number>
number of bytes written
readSync()
Section titled “readSync()”readSync(
buffer,offset?,length?,position?):number
Defined in: src/vfs/file.ts:189
Read data from the file.
Parameters
Section titled “Parameters”buffer
Section titled “buffer”ArrayBufferView
The buffer that the data will be written to.
offset?
Section titled “offset?”number = 0
The offset within the buffer where writing will start.
length?
Section titled “length?”number = ...
An integer specifying the number of bytes to read.
position?
Section titled “position?”number = ...
An integer specifying where to begin reading from in the file. If position is null, data will be read from the current file position.
Returns
Section titled “Returns”number
number of bytes written
ref():
this
Defined in: src/vfs/file.ts:78
Take another reference to the open file
Returns
Section titled “Returns”this
stat()
Section titled “stat()”stat():
InodeLike
Defined in: src/vfs/file.ts:283
Returns
Section titled “Returns”streamRead()
Section titled “streamRead()”streamRead(
options):ReadableStream
Defined in: src/vfs/file.ts:402
Create a stream for reading the file.
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”ReadableStream
Don’t repeat ourselves with the implementation in FileSystem
streamWrite()
Section titled “streamWrite()”streamWrite(
options):WritableStream
Defined in: src/vfs/file.ts:429
Create a stream for writing the file. Chunks are written to the vnode’s cache, then synced when the stream is closed.
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”WritableStream
Don’t repeat ourselves with the implementation in FileSystem
sync()
Section titled “sync()”sync():
Promise<void>
Defined in: src/vfs/file.ts:249
Returns
Section titled “Returns”Promise<void>
syncSync()
Section titled “syncSync()”syncSync():
void
Defined in: src/vfs/file.ts:107
Returns
Section titled “Returns”void
truncate()
Section titled “truncate()”truncate(
length):Promise<void>
Defined in: src/vfs/file.ts:289
Parameters
Section titled “Parameters”length
Section titled “length”number
Returns
Section titled “Returns”Promise<void>
truncateSync()
Section titled “truncateSync()”truncateSync(
length):void
Defined in: src/vfs/file.ts:141
Parameters
Section titled “Parameters”length
Section titled “length”number
Returns
Section titled “Returns”void
utimes()
Section titled “utimes()”utimes(
atime,mtime):Promise<void>
Defined in: src/vfs/file.ts:388
Change the file timestamps of the file.
Parameters
Section titled “Parameters”number
number
Returns
Section titled “Returns”Promise<void>
utimesSync()
Section titled “utimesSync()”utimesSync(
atime,mtime):void
Defined in: src/vfs/file.ts:235
Change the file timestamps of the file.
Parameters
Section titled “Parameters”number
number
Returns
Section titled “Returns”void
write()
Section titled “write()”write(
buffer,offset?,length?,position?):Promise<number>
Defined in: src/vfs/file.ts:311
Write buffer to the file.
Parameters
Section titled “Parameters”buffer
Section titled “buffer”Uint8Array
Uint8Array containing the data to write to the file.
offset?
Section titled “offset?”number = 0
Offset in the buffer to start reading data from.
length?
Section titled “length?”number = ...
The amount of bytes to write to the file.
position?
Section titled “position?”number = ...
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.
Returns
Section titled “Returns”Promise<number>
bytes written
writeSync()
Section titled “writeSync()”writeSync(
buffer,offset?,length?,position?):number
Defined in: src/vfs/file.ts:163
Write buffer to the file.
Parameters
Section titled “Parameters”buffer
Section titled “buffer”Uint8Array
Uint8Array containing the data to write to the file.
offset?
Section titled “offset?”number = 0
Offset in the buffer to start reading data from.
length?
Section titled “length?”number = ...
The amount of bytes to write to the file.
position?
Section titled “position?”number = ...
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.
Returns
Section titled “Returns”number
bytes written