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

◆ acquire_from_prefix()

Acquired< LibraryLocation > MayaFlux::Platform::detail::acquire_from_prefix ( const LibraryFromPrefix & from)
inline

Definition at line 205 of file Acquisition.hpp.

206 {
207 if (auto failure = check_file_name(from.base_name)) {
208 return std::unexpected(*failure);
209 }
210 auto absolute = resolve_absolute(from.prefix);
211 if (!absolute) {
212 return std::unexpected(absolute.error());
213 }
214 if (!path_is_directory(*absolute)) {
215 return std::unexpected(make_failure(AcquireFailure::Reason::NotDirectory, from.base_name, { *absolute }));
216 }
217
218 std::vector<std::filesystem::path> tried;
219 for (const std::string& file_name : prefix_file_names(from.base_name)) {
220 for (const char* subdir : { "lib", "lib64", "bin" }) {
221 const std::filesystem::path candidate = *absolute / subdir / file_name;
222 tried.push_back(candidate);
223 if (path_is_regular_file(candidate)) {
224 return LibraryLocation { .path = candidate, .file_name = file_name, .resolved_by_system = false };
225 }
226 }
227 }
228 return std::unexpected(make_failure(AcquireFailure::Reason::Missing, from.base_name, std::move(tried)));
229 }
std::vector< std::string > prefix_file_names(const std::string &base_name)
bool path_is_regular_file(const std::filesystem::path &path)
bool path_is_directory(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={})

References MayaFlux::Platform::LibraryFromPrefix::base_name, check_file_name(), make_failure(), MayaFlux::Platform::AcquireFailure::Missing, MayaFlux::Platform::AcquireFailure::NotDirectory, path_is_directory(), path_is_regular_file(), MayaFlux::Platform::LibraryFromPrefix::prefix, 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: