Skip to content

Rose::StringUtility::getPathFromFileName

Returns all but the last component of a path in a filesystem.

Synopsis

Declared in <src/Rose/StringUtility/FileUtility.h>

[[visibility]]
std::string
getPathFromFileName(std::string const& fileNameWithPath);

Description

This function removes the filename from the combined path and filename if it includes a path and returns only the path. Make it safe to input a filename without a path name (return the filename).

Terms are loosely defined and this function possibly doesn't work for non‐POSIX file systems; consider using std::filesystem instead.

Return Value

Path component.

Parameters

Name

Description

fileNameWithPath

Path‐like string.

Created with MrDocs