AI Disclosure: This page was generated by an LLM and may contain inaccuracies. Hand-crafted documentation will be implemented over time on the road to 1.0
FileUtilsAPI
Since Plugin API: 1.0.0
File utilities API
Signature
interface FileUtilsAPI {
getExtension(filename: string): string;
getBasename(path: string): string;
getDirname(path: string): string;
joinPath(...parts: string[]): string;
pickDirectory(options?: {
title?: string;
initialPath?: string;
}): Promise<string | null>;
readDirectory(path: string): Promise<PluginDirectoryReadResult>;
readText(path: string): Promise<PluginTextFileSnapshot>;
writeText(path: string, content: string, options: {
expectedRevision: string | null;
overwrite?: boolean;
}): Promise<PluginTextWriteResult>;
createDirectory(path: string): Promise<void>;
renamePath(source: string, destination: string): Promise<void>;
trash(paths: readonly string[]): Promise<readonly PluginPathOutcome[]>;
revealPath(path: string): Promise<void>;
toAssetUrl(path: string): Promise<string>;
readBinary(path: string): Promise<PluginBinaryFileSnapshot>;
writeBinary(path: string, content: Uint8Array, options: {
expectedRevision: string | null;
overwrite?: boolean;
}): Promise<PluginBinaryWriteResult>;
getFolderSummary(path: string, options?: {
signal?: AbortSignal;
}): Promise<FolderSummary>;
watchDirectory(path: string, handler: () => void): Promise<PluginDirectoryWatch>;
}Members
| Name | Type | Required | Description |
|---|---|---|---|
getExtension | (filename: string) => string | yes | - |
getBasename | (path: string) => string | yes | - |
getDirname | (path: string) => string | yes | - |
joinPath | (parts: string[]) => string | yes | - |
pickDirectory | (options?: { … }) => Promise<string | null> | yes | - |
readDirectory | (path: string) => Promise<PluginDirectoryReadResult> | yes | - |
readText | (path: string) => Promise<PluginTextFileSnapshot> | yes | - |
writeText | (path: string, content: string, options: { … }) => Promise<PluginTextWriteResult> | yes | - |
createDirectory | (path: string) => Promise<void> | yes | - |
renamePath | (source: string, destination: string) => Promise<void> | yes | - |
trash | (paths: readonly string[]) => Promise<readonlyPluginPathOutcome[]> | yes | - |
revealPath | (path: string) => Promise<void> | yes | - |
toAssetUrl | (path: string) => Promise<string> | yes | - |
readBinary | (path: string) => Promise<PluginBinaryFileSnapshot> | yes | - |
writeBinary | (path: string, content: Uint8Array, options: { … }) => Promise<PluginBinaryWriteResult> | yes | - |
getFolderSummary | (path: string, options?: { … }) => Promise<FolderSummary> | yes | - |
watchDirectory | (path: string, handler: () => void) => Promise<PluginDirectoryWatch> | yes | - |