From Wiki96
Jump to: navigation, search

class FS

This namespace refers to the file system API of Windows 96. w96.FS allows manipulation of file system entries by, for example, renaming, deleting or copying them. It is also possible to create, read and write files and directories.

Structure

mount(fso: IFileSystem): Promise<void>

Mounts a file system using the specified object ("driver").

umount(prefix: String): Promise<void>

Unmounts a file system instance.

mounts(): IFileSystem[]

Gets all mounted file systems.

list(): String[]

Gets all mounted file system prefixes.

nextLetter(): String

Get the next available drive letter.

toBlob(path: String): Promise<Blob>

Creates a blob from a specified path.

get(prefix: String): IFileSystem

Retuns a file system by its prefix.

toURL(path: String): Promise<String>

Creates a URL from the specified file path.

isFile(path: String): Promise<Boolean>

Returns true if the entry is a file.

isEmpty(path: String): Promise<Boolean>

Returns true if the file is empty.

mkdir(path: String): Promise<Boolean>

Creates a directory at the specified path.

rmdir(path: String): Promise<Boolean>

Deletes a directory at the specified path.

touch(path: String): Promise<Boolean>

Creates a file at the specified path.

rm(path: String): Promise<Boolean>

Deletes a file at the specified path.

readdir(path: String, scan_mode: Boolean): String[]

  • If scan_mode is set to true, then the filetype is included with the path

Returns a list of entities contained in the specified path.

cpdir(src: String, dest: String): Promise<Boolean>

Copies a directory to a new destination.

cpfile(src: String, dest: String): Promise<Boolean>

Copies a file to a new destination.

mvfile(src: String, dest: String): Promise<Boolean>

Moves a file to a new destination.

mvdir(src: String, dest: String): Promise<Boolean>

Moves a directory to a new destination.

exists(path: String): Boolean

Checks if an entity exists.

readstr(path: String): Promise<String>

Reads the specified file as a string.

readbin(path: String): Promise<Uint8Array>

Reads the specified file as binary.

filetype(path: String): 0 | 1 | -1

Returns the file type of a node. This can be a binary or text file.

writestr(path: String, data: String): Promise<Boolean>

Truncates and writes a UTF-8 encoded string to the specified file.

writebin(path: String, data: Uint8Array | Number[]): Promise<Boolean>

Truncates and writes data to the specified file.

walk(path: String): String[]

Walks through the contents of a directory.

stat(path: String): FSStatResult

Retrieves information about a file system entry.

rename(path: String, newName: String): Promise<Boolean>

Renames a file or folder.

readBinChunk(path: String, start?: Number, end?: Number): Promise<Uint8Array>

Returns a slice of a file binary data from a path, a start and an end index.

readStrChunk(path: String, start?: Number, end?: Number): Promise<String>

Returns a slice of a file as a string from a path, a start and an end index.

cache(path: String, params: { type: "binary" | "string" | "blob", overwrite: Boolean }): Promise<void>

Caches a file from a given path depending on parameters like the overwriting or the file type.

uncache(path: String): void

Uncaches the file at a specified path.

getFromCache(path: String): Uint8Array | String | Blob | undefined

Gives the the data from the cached file at a specified path. If the file wasn't cached, it returns undefined.

hash(path: String, algorithm: "default" | "md5" | "sha256" | "sha512"): Promise<String>

Creates a hash from a given path and algorithm.

assert(path: String): Promise<void>

Checks if a file exists at a specific path. If not, it will throw an Error.