Handle
Defined in: src/vfs/file.ts:20
Internal
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Handle(
context,path,internalPath,flag,vnode):Handle
Defined in: src/vfs/file.ts:83
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:22
Current position
closed
Section titled “closed”
protectedclosed:boolean=false
Defined in: src/vfs/file.ts:64
Whether the file is open or closed
context
Section titled “context”
readonlycontext:unknown
Defined in: src/vfs/file.ts:84
readonlyflag:number
Defined in: src/vfs/file.ts:87
internalPath
Section titled “internalPath”
readonlyinternalPath:string
Defined in: src/vfs/file.ts:86
readonlypath:string
Defined in: src/vfs/file.ts:85
protectedrefs:number=1
Defined in: src/vfs/file.ts:67
How many descriptors refer to this open file
readonlyvnode:VNode
Defined in: src/vfs/file.ts:88
Accessors
Section titled “Accessors”_isSync
Section titled “_isSync”Get Signature
Section titled “Get Signature”get
protected_isSync():boolean
Defined in: src/vfs/file.ts:91
Returns
Section titled “Returns”boolean
Get Signature
Section titled “Get Signature”get
protecteddirty():boolean
Defined in: src/vfs/file.ts:57
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:50
Returns
Section titled “Returns”Get Signature
Section titled “Get Signature”get inode():
InodeLike
Defined in: src/vfs/file.ts:45
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:76
Returns
Section titled “Returns”boolean
position
Section titled “position”Get Signature
Section titled “Get Signature”get position():
number
Defined in: src/vfs/file.ts:33
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:37
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:237
Returns
Section titled “Returns”Promise<void>
[dispose]()
Section titled “[dispose]()”[dispose]():
void
Defined in: src/vfs/file.ts:95
Returns
Section titled “Returns”void
chmod()
Section titled “chmod()”chmod(
mode):Promise<void>
Defined in: src/vfs/file.ts:363
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”Promise<void>
chmodSync()
Section titled “chmodSync()”chmodSync(
mode):void
Defined in: src/vfs/file.ts:205
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:372
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:214
Parameters
Section titled “Parameters”number
number
Returns
Section titled “Returns”void
close()
Section titled “close()”close():
Promise<void>
Defined in: src/vfs/file.ts:257
Returns
Section titled “Returns”Promise<void>
closeSync()
Section titled “closeSync()”closeSync():
void
Defined in: src/vfs/file.ts:115
Returns
Section titled “Returns”void
datasync()
Section titled “datasync()”datasync():
Promise<void>
Defined in: src/vfs/file.ts:253
Default implementation maps to sync.
Returns
Section titled “Returns”Promise<void>
datasyncSync()
Section titled “datasyncSync()”datasyncSync():
void
Defined in: src/vfs/file.ts:111
Default implementation maps to syncSync.
Returns
Section titled “Returns”void
dispose()
Section titled “dispose()”
protecteddispose(force?):void
Defined in: src/vfs/file.ts:267
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:125
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:335
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 | null
An integer specifying where to begin reading from in the file. If position is null, data will be read from the current file position, which is then advanced.
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:182
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 | null
An integer specifying where to begin reading from in the file. If position is null, data will be read from the current file position, which is then advanced.
Returns
Section titled “Returns”number
number of bytes written
ref():
this
Defined in: src/vfs/file.ts:70
Take another reference to the open file
Returns
Section titled “Returns”this
stat()
Section titled “stat()”stat():
InodeLike
Defined in: src/vfs/file.ts:275
Returns
Section titled “Returns”streamRead()
Section titled “streamRead()”streamRead(
options):ReadableStream
Defined in: src/vfs/file.ts:398
Create a stream for reading the file from start, or from the current position (which is then advanced) if not given.
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”ReadableStream
streamWrite()
Section titled “streamWrite()”streamWrite(
options):WritableStream
Defined in: src/vfs/file.ts:430
Create a stream for writing the file at start, or at the current position (which is then advanced) if not given.
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:241
Returns
Section titled “Returns”Promise<void>
syncSync()
Section titled “syncSync()”syncSync():
void
Defined in: src/vfs/file.ts:99
Returns
Section titled “Returns”void
truncate()
Section titled “truncate()”truncate(
length):Promise<void>
Defined in: src/vfs/file.ts:281
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:133
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:384
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:226
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:303
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 | null
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, which is then advanced.
Returns
Section titled “Returns”Promise<number>
bytes written
writeSync()
Section titled “writeSync()”writeSync(
buffer,offset?,length?,position?):number
Defined in: src/vfs/file.ts:155
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 | null
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, which is then advanced.
Returns
Section titled “Returns”number
bytes written