Skip to main content

Vault

Extends Events

Constructor#

constructor();

Properties#

adapter#

adapter: DataAdapter

configDir#

configDir: string

Gets the path to the config folder. This value is typically .obsidian but it could be different.

Methods#

getName#

getName(): string;

Gets the name of the vault

getAbstractFileByPath#

getAbstractFileByPath(path: string): TAbstractFile | null;

getRoot#

getRoot(): TFolder;

create#

create(path: string, data: string, options?: DataWriteOptions): Promise<TFile>;

createBinary#

createBinary(path: string, data: ArrayBuffer, options?: DataWriteOptions): Promise<TFile>;

createFolder#

createFolder(path: string): Promise<void>;

read#

read(file: TFile): Promise<string>;

cachedRead#

cachedRead(file: TFile): Promise<string>;

readBinary#

readBinary(file: TFile): Promise<ArrayBuffer>;

getResourcePath#

getResourcePath(file: TFile): string;

delete#

delete(file: TAbstractFile, force?: boolean): Promise<void>;

trash#

trash(file: TAbstractFile, system: boolean): Promise<void>;

Tries to move to system trash. If that isn't successful/allowed, use local trash

rename#

rename(file: TAbstractFile, newPath: string): Promise<void>;

modify#

modify(file: TFile, data: string, options?: DataWriteOptions): Promise<void>;

modifyBinary#

modifyBinary(file: TFile, data: ArrayBuffer, options?: DataWriteOptions): Promise<void>;

append#

append(file: TFile, data: string, options?: DataWriteOptions): Promise<void>;

copy#

copy(file: TFile, newPath: string): Promise<TFile>;

getAllLoadedFiles#

getAllLoadedFiles(): TAbstractFile[];

recurseChildren#

static recurseChildren(root: TFolder, cb: (file: TAbstractFile) => any): void;

getMarkdownFiles#

getMarkdownFiles(): TFile[];

getFiles#

getFiles(): TFile[];

on#

on(name: 'create', callback: (file: TAbstractFile) => any, ctx?: any): EventRef;

on#

on(name: 'modify', callback: (file: TAbstractFile) => any, ctx?: any): EventRef;

on#

on(name: 'delete', callback: (file: TAbstractFile) => any, ctx?: any): EventRef;

on#

on(name: 'rename', callback: (file: TAbstractFile, oldPath: string) => any, ctx?: any): EventRef;

on#

on(name: 'closed', callback: () => any, ctx?: any): EventRef;