- Remove unused vault.delete() method in favor of trashFile() - Replace \x00-\x1F with \u0000-\u001F for clearer regex syntax - Verify no unused imports, variables, or scoping issues All cleanup tasks verified with tsc --noUnusedLocals --noUnusedParameters
49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
import { Vault, TAbstractFile, TFile, TFolder, DataWriteOptions } from 'obsidian';
|
|
import { IVaultAdapter } from './interfaces';
|
|
|
|
export class VaultAdapter implements IVaultAdapter {
|
|
constructor(private vault: Vault) {}
|
|
|
|
async read(file: TFile): Promise<string> {
|
|
return this.vault.read(file);
|
|
}
|
|
|
|
stat(file: TAbstractFile): { ctime: number; mtime: number; size: number } | null {
|
|
if (file instanceof TFile) {
|
|
return file.stat;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
getAbstractFileByPath(path: string): TAbstractFile | null {
|
|
return this.vault.getAbstractFileByPath(path);
|
|
}
|
|
|
|
getMarkdownFiles(): TFile[] {
|
|
return this.vault.getMarkdownFiles();
|
|
}
|
|
|
|
getRoot(): TFolder {
|
|
return this.vault.getRoot();
|
|
}
|
|
|
|
async process(file: TFile, fn: (data: string) => string, options?: DataWriteOptions): Promise<string> {
|
|
return this.vault.process(file, fn, options);
|
|
}
|
|
|
|
async createFolder(path: string): Promise<void> {
|
|
await this.vault.createFolder(path);
|
|
}
|
|
|
|
async create(path: string, data: string): Promise<TFile> {
|
|
return this.vault.create(path, data);
|
|
}
|
|
|
|
async modify(file: TFile, data: string): Promise<void> {
|
|
await this.vault.modify(file, data);
|
|
}
|
|
|
|
async trash(file: TAbstractFile, system: boolean): Promise<void> {
|
|
await this.vault.trash(file, system);
|
|
}
|
|
} |