fs builtin (highly experimental and potentially dangerous)

This commit is contained in:
Zef Hemel
2022-07-06 12:17:42 +02:00
parent 0388b6a2a4
commit f1a7cc1fb7
3 changed files with 121 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
import { syscall } from "./syscall";
export type FileMeta = {
name: string;
lastModified: number;
};
export async function readFile(
path: string
): Promise<{ text: string; meta: FileMeta }> {
return syscall("fs.readFile", path);
}
export async function getFileMeta(path: string): Promise<FileMeta> {
return syscall("fs.getFileMeta", path);
}
export async function writeFile(path: string, text: string): Promise<FileMeta> {
return syscall("fs.writeFile", path, text);
}
export async function deleteFile(path: string): Promise<void> {
return syscall("fs.deleteFile", path);
}
export async function listFiles(
dirName: string,
recursive = false
): Promise<FileMeta[]> {
return syscall("fs.listFiles", dirName, recursive);
}