This commit is contained in:
Andras Schmelczer 2025-03-22 12:01:06 +00:00
parent 7dcdc98b60
commit 16aac488cc
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C

View file

@ -1,16 +1,33 @@
import type { RelativePath } from "../persistence/database"; import type { RelativePath } from "../persistence/database";
export interface FileSystemOperations { export interface FileSystemOperations {
// List all files that should be synced.
listAllFiles: () => Promise<RelativePath[]>; listAllFiles: () => Promise<RelativePath[]>;
// Read the content of a file.
read: (path: RelativePath) => Promise<Uint8Array>; read: (path: RelativePath) => Promise<Uint8Array>;
// Create or overwrite a file with the given content.
write: (path: RelativePath, content: Uint8Array) => Promise<void>; write: (path: RelativePath, content: Uint8Array) => Promise<void>;
// Atomically update the content of a text file.
atomicUpdateText: ( atomicUpdateText: (
path: RelativePath, path: RelativePath,
updater: (currentContent: string) => string updater: (currentContent: string) => string
) => Promise<string>; ) => Promise<string>;
// Get the size of a file in bytes.
getFileSize: (path: RelativePath) => Promise<number>; getFileSize: (path: RelativePath) => Promise<number>;
// Check if a file exists.
exists: (path: RelativePath) => Promise<boolean>; exists: (path: RelativePath) => Promise<boolean>;
// Create a directory at the specified path. All parent directories must already exist.
createDirectory: (path: RelativePath) => Promise<void>; createDirectory: (path: RelativePath) => Promise<void>;
// Delete a file. It is expected that the path points to an existing file.
delete: (path: RelativePath) => Promise<void>; delete: (path: RelativePath) => Promise<void>;
// Rename a file. It is expected that the oldPath points to an existing file and the newPath does not exist.
rename: (oldPath: RelativePath, newPath: RelativePath) => Promise<void>; rename: (oldPath: RelativePath, newPath: RelativePath) => Promise<void>;
} }