Massive restructure of plugin API
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { syscall } from "./syscall.ts";
|
||||
|
||||
export type FileMeta = {
|
||||
name: string;
|
||||
lastModified: number;
|
||||
};
|
||||
|
||||
export function readFile(
|
||||
path: string,
|
||||
encoding: "utf8" | "dataurl" = "utf8",
|
||||
): Promise<string> {
|
||||
return syscall("fs.readFile", path, encoding);
|
||||
}
|
||||
|
||||
export function getFileMeta(path: string): Promise<FileMeta> {
|
||||
return syscall("fs.getFileMeta", path);
|
||||
}
|
||||
|
||||
export function writeFile(
|
||||
path: string,
|
||||
text: string,
|
||||
encoding: "utf8" | "dataurl" = "utf8",
|
||||
): Promise<FileMeta> {
|
||||
return syscall("fs.writeFile", path, text, encoding);
|
||||
}
|
||||
|
||||
export function deleteFile(path: string): Promise<void> {
|
||||
return syscall("fs.deleteFile", path);
|
||||
}
|
||||
|
||||
export function listFiles(
|
||||
dirName: string,
|
||||
recursive = false,
|
||||
): Promise<FileMeta[]> {
|
||||
return syscall("fs.listFiles", dirName, recursive);
|
||||
}
|
||||
Reference in New Issue
Block a user