Skip to content

getFileOrNull

Retrieves a file or null based on the provided path or file. If the provided argument is already a file, it is returned as is. Otherwise, the function uses the app’s vault to retrieve the file by its path.

Import:

import { getFileOrNull } from 'obsidian-dev-utils/obsidian/file-system';

Signature:

function getFileOrNull(params: GetFileOrNullParams): TFile | null

Parameters:

ParameterTypeDescription
paramsGetFileOrNullParamsThe parameters for the retrieval.

Returns: TFile | null — The file if found, otherwise null.


Links to this page: