Add more file operations

This commit is contained in:
Andras Schmelczer 2024-12-18 20:35:36 +00:00
commit c0fd041532
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C

View file

@ -7,12 +7,23 @@ import { RelativePath } from "src/database/document-metadata";
export class ObsidianFileOperations implements FileOperations {
public constructor(private vault: Vault) {}
async listAllFiles(): Promise<RelativePath[]> {
const files = this.vault.getFiles();
return files.map((file) => file.path);
}
async read(path: RelativePath): Promise<Uint8Array> {
return new Uint8Array(
await this.vault.adapter.readBinary(normalizePath(path))
);
}
async getModificationTime(path: RelativePath): Promise<Date> {
return new Date(
(await this.vault.adapter.stat(normalizePath(path)))!.mtime
);
}
async write(
path: RelativePath,
expectedContent: Uint8Array,