Skip to content

getOrCreateFileSafe

Gets or creates a file safely in the specified path.

If the file already exists, it will be returned. If the file does not exist, it will be created and returned.

Import:

import { getOrCreateFileSafe } from 'obsidian-dev-utils/obsidian/vault';

Signature:

function getOrCreateFileSafe(app: App, path: string): Promise<TFile>

Parameters:

ParameterTypeDescription
appAppThe application instance.
pathstringThe path of the file to get or create.

Returns: Promise<TFile> — A Promise that resolves to the file.