MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ resolve_path()

static std::string MayaFlux::IO::FileReader::resolve_path ( const std::string &  filepath)
inlinestatic

Resolve a filepath against the project source root if not found as-is.

Absolute paths are returned unchanged. Relative paths are tried as-is first, then prefixed with the project root. Returns the original path if neither resolves, allowing the caller to fail naturally.

Parameters
filepathPath as supplied by the caller.
Returns
Resolved path string.

Definition at line 268 of file FileReader.hpp.

269 {
270 namespace fs = std::filesystem;
271 auto normalized = std::string(filepath);
272 std::ranges::replace(normalized, '\\', '/');
273
274 if (fs::path(normalized).is_absolute())
275 return normalized;
276 if (fs::exists(normalized))
277 return normalized;
278 auto from_cwd = fs::current_path() / normalized;
279 if (fs::exists(from_cwd))
280 return from_cwd.string();
281 auto from_root = fs::path(Config::project_root()) / normalized;
282 if (fs::exists(from_root))
283 return from_root.string();
284 return normalized;
285 }
std::string project_root()

Referenced by MayaFlux::IO::SoundFileReader::can_read(), MayaFlux::IO::FileReaderRegistry::create_reader(), MayaFlux::IO::ImageReader::load(), MayaFlux::IO::Detail::make_default_resolver(), MayaFlux::IO::SpatialReader::open(), MayaFlux::IO::SoundFileReader::open(), MayaFlux::IO::DelimitedTextReader::open(), MayaFlux::IO::ImageReader::open(), MayaFlux::IO::ModelReader::open(), MayaFlux::IO::VideoFileReader::open(), and MayaFlux::IO::VolumeReader::open().

+ Here is the caller graph for this function: