Refactoring

This commit is contained in:
Zef Hemel
2023-08-20 17:51:00 +02:00
parent 75bdd6390b
commit a94724768e
34 changed files with 226 additions and 47 deletions
+22
View File
@@ -1,3 +1,4 @@
import { FileMeta } from "$sb/types.ts";
import { SysCallMapping } from "../../plugos/system.ts";
import type { Space } from "../../web/space.ts";
import { AttachmentMeta, PageMeta } from "../../web/types.ts";
@@ -57,5 +58,26 @@ export function spaceSyscalls(space: Space): SysCallMapping {
"space.deleteAttachment": async (_ctx, name: string) => {
await space.deleteAttachment(name);
},
// FS
"space.listFiles": (): Promise<FileMeta[]> => {
return space.spacePrimitives.fetchFileList();
},
"space.getFileMeta": (_ctx, name: string): Promise<FileMeta> => {
return space.spacePrimitives.getFileMeta(name);
},
"space.readFile": async (_ctx, name: string): Promise<Uint8Array> => {
return (await space.spacePrimitives.readFile(name)).data;
},
"space.writeFile": (
_ctx,
name: string,
data: Uint8Array,
): Promise<FileMeta> => {
return space.spacePrimitives.writeFile(name, data);
},
"space.deleteFile": (_ctx, name: string) => {
return space.spacePrimitives.deleteFile(name);
},
};
}