FileDescriptors
FileDescriptors
FileDescriptor
Class representing a File Descriptor
new FileDescriptor(inode: $Subtype<
INode>, flags:
number)
Parameters
Instance Members
▸
constructor(inode, flags)
Creates FileDescriptor
Starts the seek position at 0
Parameters
Gets an INode.
getINode(): $Subtype<
INode>
Returns
$Subtype<INode>
Gets the file descriptor flags.
Unlike Linux filesystems, this retains creation and status flags.
Returns
number
Sets the file descriptor flags.
Parameters
Returns
void
Gets the file descriptor position.
Returns
number
Sets the file descriptor position.
Parameters
Returns
void
Throws
Reads from this file descriptor into a buffer.
It will always try to fill the input buffer.
If position is specified, the position change does not persist.
If the current file descriptor position is greater than the length of the data, this will read 0 bytes.
Parameters
position ((number | null)
= null
)
Returns
number
Throws
▸
write(buffer, position, extraFlags)
Writes to this file descriptor.
If position is specified, the position change does not persist.
Parameters
position ((number | null)
= null
)
Throws
Truncates this file descriptor.
Parameters
Throws
FileDescriptorManager
Class that manages all FileDescriptors
new FileDescriptorManager()
Instance Members
Creates an instance of the FileDescriptorManager.
It starts the fd counter at 0.
Make sure not get real fd numbers confused with these fd numbers.
constructor()
Creates a file descriptor.
While a file descriptor is opened, the underlying iNode can still be garbage collected by the INodeManager, but it won't be garbage collected by JavaScript runtime.
Parameters
Returns
{index: number, fd: FileDescriptor}
Deletes a file descriptor.
This effectively closes the file descriptor.
Parameters
Returns
void
INode
Class representing an iNode.
Parameters
Instance Members
▸
constructor(metadata, iNodeMgr)
Creates iNode.
INode and INodeManager will recursively call each other.
Parameters
File
Class representing a file.
Extends
INode
Parameters
Instance Members
▸
constructor(props, iNodeMgr)
Creates a file.
Parameters
Gets the file buffer.
Returns
Buffer
Sets the file buffer.
Parameters
Returns
void
Noop.
destructor(): void
Returns
void
Directory
Class representing a directory.
Extends
INode
Parameters
Instance Members
▸
constructor(props, iNodeMgr)
Creates a directory.
Virtual directories have 0 size.
If there's no parent inode, we assume this is the root directory.
Parameters
Gets all the names.
getEntries():
Map<any, any>
Returns
Map<any, any>
Get the inode index for a name.
Parameters
Returns
number?
Get inode for a name.
Parameters
Returns
($Subtype<INode> | void)
Add a name to inode index to this directory.
It will increment the link reference to the inode.
Parameters
Delete a name in this directory.
It will decrement the link reference to the inode.
deleteEntry(name:
string): void
Parameters
Returns
void
▸
renameEntry(oldName, newName)
Rename a name in this directory.
Parameters
Returns
void
This is to be called by the INodeManager all hardlinks to this directory reduce to 0.
destructor(): void
Returns
void
Symlink
Class representing a Symlink.
Extends
INode
Parameters
Instance Members
▸
constructor(props, iNodeMgr)
Creates a symlink.
Parameters
Gets the link string.
Returns
string
Noop.
destructor(): void
Returns
void
INodeManager
Class that manages all iNodes including creation and deletion
new INodeManager()
Instance Members
Creates an instance of the INodeManager.
It starts the inode counter at 1, as 0 is usually reserved in posix filesystems.
constructor()
▸
createINode(iNodeConstructor, props)
Creates an inode, from a INode constructor function.
The returned inode index must be added as an entry into a directory.
Parameters
iNodeConstructor (Class<INode>)
Returns
number
Links an inode, this increments the hardlink reference count.
linkINode(index:
number): void
Parameters
Returns
void
Unlinks an inode, this decrements the hardlink reference count.
If the hardlink reference count reaches 0, the inode is garbage collected.
unlinkINode(index:
number): void
Parameters
Returns
void
Stat
Stat
Instance Members
Creates Stat.
constructor(props: Metadata)
Parameters
Checks if directory.
Returns
boolean
Checks if block device.
Returns
boolean
Checks if character device.
Returns
boolean
Checks if symbolic link.
Returns
boolean
Stat
Class representing Stat metadata.
new Stat(props: Metadata)
Parameters
Instance Members
Creates Stat.
constructor(props: Metadata)
Parameters
Checks if directory.
Returns
boolean
Checks if block device.
Returns
boolean
Checks if character device.
Returns
boolean
Checks if symbolic link.
Returns
boolean
ReadStream
Class representing a ReadStream.
Extends
Readable
Parameters
Instance Members
▸
constructor(path, options, fs)
Creates ReadStream.
It will asynchronously open the file descriptor if a file path was passed in.
It will automatically close the opened file descriptor by default.
Parameters
WriteStream
Class representing a WriteStream.
Extends
Writable
Parameters
Instance Members
▸
constructor(path, options, fs)
Creates WriteStream.
Parameters
VirtualFS
VirtualFS
Instance Members
Creates VirtualFS.
constructor()
VirtualFS
Class representing a virtual filesystem.
new VirtualFS()
Instance Members
Creates VirtualFS.
constructor()
VirtualFSError
Class representing a file system error.
new VirtualFSError(errorSys: any, path: any, dest: any, syscall: any)
Extends
Error
Parameters
Instance Members
▸
constructor(errorSys, path, dest, syscall)
Creates VirtualFSError.
constructor(errorSys: any, path: any, dest: any, syscall: any)
Parameters