MayaFlux 0.5.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 SOURCE_DIR. 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 270 of file FileReader.hpp.

271 {
272 namespace fs = std::filesystem;
273 auto normalized = std::string(filepath);
274 std::ranges::replace(normalized, '\\', '/');
275
276 if (fs::path(normalized).is_absolute())
277 return normalized;
278 if (fs::exists(normalized))
279 return normalized;
280 auto from_cwd = fs::current_path() / normalized;
281 if (fs::exists(from_cwd))
282 return from_cwd.string();
283 auto from_root = fs::path(Config::SOURCE_DIR) / normalized;
284 if (fs::exists(from_root))
285 return from_root.string();
286 return normalized;
287 }
std::vector< double > normalized(const std::vector< double > &data, double target_peak)
Normalize single-channel data (non-destructive)
Definition Yantra.cpp:588

References MayaFlux::normalized().

Referenced by MayaFlux::IO::SoundFileReader::can_read(), MayaFlux::IO::FileReaderRegistry::create_reader(), MayaFlux::IO::ImageReader::load(), MayaFlux::IO::ImageReader::load_texture(), MayaFlux::IO::ImageReader::open(), MayaFlux::IO::ModelReader::open(), MayaFlux::IO::SoundFileReader::open(), and MayaFlux::IO::VideoFileReader::open().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: