Class Filesystem
Constructors
constructor
-
new Filesystem(
storage: StorageProvider,
sources?: {
fetch?: (url: string, init?: RequestInit) => Promise<Response>;
initfs?: string | false;
key?: (key: string) => string;
},
): FilesystemParameters
- storage: StorageProvider
- sources: {
fetch?: (url: string, init?: RequestInit) => Promise<Response>;
initfs?: string | false;
key?: (key: string) => string;
} = {}
Returns Filesystem
Accessors
config
-
get config(): Configuration<ConfigMounts>
Returns Configuration<ConfigMounts>
The filesystem options.
constants
-
get constants(): __module
Returns __module
Constants related to the filesystem.
fs
-
get fs(): __module
Returns __module
The asynchronous ZenFS filesystem instance.
fsSync
-
get fsSync(): __module
Returns __module
The synchronous ZenFS filesystem instance.
mounts
-
Returns Map<string, FileSystem>
The mounted filesystems.
Methods
configure
copyTree
-
Recursively copies every file and directory under
sourcetodestination, both mounted paths (possibly on different backends). The primitive for moving a filesystem's contents onto another backend; there is no automatic root swap, sinceroot=is not parsed.Parameters
- source: string
- destination: string
Returns Promise<number>
the number of files copied (directories are not counted)
descriptions
exists
-
Checks if a file or directory exists at the given path.
Parameters
- path: string
The path to check.
Returns Promise<boolean>
A promise that resolves to true if the path exists, false otherwise.
- path: string
extractTarball
-
extractTarball(
tarballPath: string,
extractPath: string,
fileMode?: number,
directoryMode?: number,
filter?: (name: string) => boolean,
): Promise<void>Extracts a tarball to the given path.
Parameters
- tarballPath: string
The path to the tarball.
- extractPath: string
The path to extract the tarball to.
- fileMode: number = 0o644
The mode to set for files. Defaults to 0o644.
- directoryMode: number = 0o755
The mode to set for directories. Defaults to 0o755.
Optionalfilter: (name: string) => boolean
Returns Promise<void>
A promise that resolves when the tarball is extracted.
- tarballPath: string
Staticoptions
-
Returns the default filesystem options with the given extensions.
Type Parameters
- T extends ConfigMounts
Parameters
Optionalextensions: Partial<FilesystemOptions<T>>The extensions to apply to the default options.
Returns FilesystemOptions<T>
The filesystem options with the given extensions.
initfsoverrides where the initfs tarball is (falseinstalls none);fetchis what reads it