dash.assert.fileExists

Throw error if a file does not exist


Syntax



Description

abspath = dash.assert.fileExists(filename)

Checks if a file exists. If not, throws an error. If so, returns the absolute path to the file as a string.

abspath = dash.assert.fileExists(filename, ext)

Also checks for files with the given extension.

abspath = dash.assert.fileExists(filename, ext, idHeader)

Uses a custom header in thrown error IDs.


Input Arguments

filename

string scalar
The name of a file

ext

string scalar | empty array
Default file extension. Leave unset, or use an empty array to not check extensions.

idHeader

string scalar
Header to use in thrown error IDs. Default is “DASH:assert:fileExists”

Output Arguments

abspath

string scalar
The absolute path to the file