(Started this page) |
(Filled every single methods) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 19: | Line 19: | ||
Get the next available drive letter. | Get the next available drive letter. | ||
=== <code>toBlob(path: String): | === <code>toBlob(path: String): Promise<Blob></code> === | ||
Creates a blob from a specified path. | Creates a blob from a specified path. | ||
Line 25: | Line 25: | ||
Retuns a file system by its prefix. | Retuns a file system by its prefix. | ||
=== <code>toURL(path: String): | === <code>toURL(path: String): Promise<String></code> === | ||
Creates a URL from the specified file path. | Creates a URL from the specified file path. | ||
=== <code>isFile(path: String): | === <code>isFile(path: String): Promise<Boolean></code> === | ||
Returns <code>true</code> if the entry is a file. | Returns <code>true</code> if the entry is a file. | ||
=== <code>isEmpty(path: String): | === <code>isEmpty(path: String): Promise<Boolean></code> === | ||
Returns <code>true</code> if the file is empty. | Returns <code>true</code> if the file is empty. | ||
=== <code>mkdir(path: String): | === <code>mkdir(path: String): Promise<Boolean></code> === | ||
Creates a directory at the specified path. | Creates a directory at the specified path. | ||
=== <code>rmdir(path: String): | === <code>rmdir(path: String): Promise<Boolean></code> === | ||
Deletes a directory at the specified path. | Deletes a directory at the specified path. | ||
=== <code>touch(path: String): | === <code>touch(path: String): Promise<Boolean></code> === | ||
Creates a file at the specified path. | Creates a file at the specified path. | ||
=== <code>rm(path: String): | === <code>rm(path: String): Promise<Boolean></code> === | ||
Deletes a file at the specified path. | Deletes a file at the specified path. | ||
=== <code>readdir(path: String): String[]</code> === | === <code>readdir(path: String, scan_mode: Boolean): String[]</code> === | ||
* 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. | Returns a list of entities contained in the specified path. | ||
Line 88: | Line 91: | ||
Renames a file or folder. | Renames a file or folder. | ||
=== <code>readBinChunk()</code> === | === <code>readBinChunk(path: String, start?: Number, end?: Number): Promise<Uint8Array></code> === | ||
Returns a slice of a file binary data from a path, a start and an end index. | |||
=== <code>readStrChunk()</code> === | === <code>readStrChunk(path: String, start?: Number, end?: Number): Promise<String></code> === | ||
Returns a slice of a file as a string from a path, a start and an end index. | |||
=== <code>cache()</code> === | === <code>cache(path: String, params: { type: "binary" | "string" | "blob", overwrite: Boolean }): Promise<void></code> === | ||
Caches a file from a given path depending on parameters like the overwriting or the file type. | |||
=== <code>uncache()</code> === | === <code>uncache(path: String): void</code> === | ||
Uncaches the file at a specified path. | |||
=== <code>getFromCache()</code> === | === <code>getFromCache(path: String): Uint8Array | String | Blob | undefined</code> === | ||
Gives the the data from the cached file at a specified path. If the file wasn't cached, it returns <code>undefined</code>. | |||
=== <code>hash(path: String, algorithm: "default" | "md5" | "sha256" | "sha512"): Promise<String></code> === | === <code>hash(path: String, algorithm: "default" | "md5" | "sha256" | "sha512"): Promise<String></code> === | ||
Creates a hash from a given path and algorithm. | |||
=== <code>assert()</code> === | === <code>assert(path: String): Promise<void></code> === | ||
Checks if a file exists at a specific path. If not, it will throw an <code>Error</code>. | |||
[[Category:API]] | [[Category:API]] |
Latest revision as of 19:53, 22 December 2023
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
.