Skip to content

DataAdapter.exists method

DataAdapter › exists

Official

Check if something exists at the given path. For a faster way to synchronously check if a note or attachment is in the vault, use Vault.getAbstractFileByPath.

Signature:

exists(normalizedPath: string, sensitive?: boolean | undefined): Promise<boolean>

Parameters:

ParameterTypeDescription
normalizedPathstringpath to file/folder, use {@link normalizePath} to normalize beforehand.
sensitive?boolean | undefinedSome file systems/operating systems are case-insensitive, set to true to force a case-sensitivity check.

Returns: Promise<boolean>

Example:

const path = normalizePath(`${plugin.manifest.dir}/cache.json`);
if (await adapter.exists(path)) {
const cache = JSON.parse(await adapter.read(path));
}