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

◆ acquire_from_directories()

Acquired< LibraryLocation > MayaFlux::Platform::detail::acquire_from_directories ( const LibraryFromDirectories & from)
inline

Definition at line 231 of file Acquisition.hpp.

232 {
233 if (auto failure = check_file_name(from.base_name)) {
234 return std::unexpected(*failure);
235 }
236
237 std::vector<std::filesystem::path> directories;
238 for (const std::filesystem::path& directory : from.directories) {
239 if (directory.empty()) {
240 continue;
241 }
242 auto absolute = resolve_absolute(directory);
243 if (!absolute) {
244 return std::unexpected(absolute.error());
245 }
246 directories.push_back(std::move(*absolute));
247 }
248 if (directories.empty()) {
249 return std::unexpected(make_failure(AcquireFailure::Reason::EmptyRequest, from.base_name));
250 }
251
252 std::vector<std::filesystem::path> tried;
253 for (const std::string& file_name : prefix_file_names(from.base_name)) {
254 for (const std::filesystem::path& directory : directories) {
255 const std::filesystem::path candidate = directory / file_name;
256 tried.push_back(candidate);
257 if (path_is_regular_file(candidate)) {
258 return LibraryLocation { .path = candidate, .file_name = file_name, .resolved_by_system = false };
259 }
260 }
261 }
262 return std::unexpected(make_failure(AcquireFailure::Reason::Missing, from.base_name, std::move(tried)));
263 }
std::vector< std::string > prefix_file_names(const std::string &base_name)
bool path_is_regular_file(const std::filesystem::path &path)
std::optional< AcquireFailure > check_file_name(std::string_view name)
std::expected< std::filesystem::path, AcquireFailure > resolve_absolute(const std::filesystem::path &path)
AcquireFailure make_failure(AcquireFailure::Reason reason, std::string request, std::vector< std::filesystem::path > tried={})
std::vector< std::filesystem::path > directories

References MayaFlux::Platform::LibraryFromDirectories::base_name, check_file_name(), MayaFlux::Platform::LibraryFromDirectories::directories, MayaFlux::Platform::AcquireFailure::EmptyRequest, make_failure(), MayaFlux::Platform::AcquireFailure::Missing, path_is_regular_file(), prefix_file_names(), and resolve_absolute().

Referenced by MayaFlux::Platform::acquire_library().

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