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:
| Parameter | Type | Description |
|---|---|---|
| normalizedPath | string | path to file/folder, use {@link normalizePath} to normalize beforehand. |
| sensitive? | boolean | undefined | Some file systems/operating systems are case-insensitive, set to true to force a case-sensitivity check. |
Example:
const path = normalizePath(`${plugin.manifest.dir}/cache.json`);if (await adapter.exists(path)) { const cache = JSON.parse(await adapter.read(path));}