mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-24 14:45:41 +00:00
DynamicLibrary: Add patch to versioned filename
This commit is contained in:
parent
40356fc381
commit
876f212685
|
@ -54,10 +54,12 @@ std::string DynamicLibrary::GetUnprefixedFilename(const char* filename)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DynamicLibrary::GetVersionedFilename(const char* libname, int major, int minor)
|
std::string DynamicLibrary::GetVersionedFilename(const char* libname, int major, int minor, int patch)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
if (major >= 0 && minor >= 0)
|
if (major >= 0 && minor >= 0 && patch >= 0)
|
||||||
|
return fmt::format("{}-{}-{}-{}.dll", libname, major, minor, patch);
|
||||||
|
else if (major >= 0 && minor >= 0)
|
||||||
return fmt::format("{}-{}-{}.dll", libname, major, minor);
|
return fmt::format("{}-{}-{}.dll", libname, major, minor);
|
||||||
else if (major >= 0)
|
else if (major >= 0)
|
||||||
return fmt::format("{}-{}.dll", libname, major);
|
return fmt::format("{}-{}.dll", libname, major);
|
||||||
|
@ -65,7 +67,9 @@ std::string DynamicLibrary::GetVersionedFilename(const char* libname, int major,
|
||||||
return fmt::format("{}.dll", libname);
|
return fmt::format("{}.dll", libname);
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
const char* prefix = std::strncmp(libname, "lib", 3) ? "lib" : "";
|
const char* prefix = std::strncmp(libname, "lib", 3) ? "lib" : "";
|
||||||
if (major >= 0 && minor >= 0)
|
if (major >= 0 && minor >= 0 && patch >= 0)
|
||||||
|
return fmt::format("{}{}.{}.{}.{}.dylib", prefix, libname, major, minor, patch);
|
||||||
|
else if (major >= 0 && minor >= 0)
|
||||||
return fmt::format("{}{}.{}.{}.dylib", prefix, libname, major, minor);
|
return fmt::format("{}{}.{}.{}.dylib", prefix, libname, major, minor);
|
||||||
else if (major >= 0)
|
else if (major >= 0)
|
||||||
return fmt::format("{}{}.{}.dylib", prefix, libname, major);
|
return fmt::format("{}{}.{}.dylib", prefix, libname, major);
|
||||||
|
@ -73,7 +77,9 @@ std::string DynamicLibrary::GetVersionedFilename(const char* libname, int major,
|
||||||
return fmt::format("{}{}.dylib", prefix, libname);
|
return fmt::format("{}{}.dylib", prefix, libname);
|
||||||
#else
|
#else
|
||||||
const char* prefix = std::strncmp(libname, "lib", 3) ? "lib" : "";
|
const char* prefix = std::strncmp(libname, "lib", 3) ? "lib" : "";
|
||||||
if (major >= 0 && minor >= 0)
|
if (major >= 0 && minor >= 0 && patch >= 0)
|
||||||
|
return fmt::format("{}{}.so.{}.{}.{}", prefix, libname, major, minor, patch);
|
||||||
|
else if (major >= 0 && minor >= 0)
|
||||||
return fmt::format("{}{}.so.{}.{}", prefix, libname, major, minor);
|
return fmt::format("{}{}.so.{}.{}", prefix, libname, major, minor);
|
||||||
else if (major >= 0)
|
else if (major >= 0)
|
||||||
return fmt::format("{}{}.so.{}", prefix, libname, major);
|
return fmt::format("{}{}.so.{}", prefix, libname, major);
|
||||||
|
|
|
@ -33,10 +33,10 @@ public:
|
||||||
/// Returns the specified library name in platform-specific format.
|
/// Returns the specified library name in platform-specific format.
|
||||||
/// Major/minor versions will not be included if set to -1.
|
/// Major/minor versions will not be included if set to -1.
|
||||||
/// If libname already contains the "lib" prefix, it will not be added again.
|
/// If libname already contains the "lib" prefix, it will not be added again.
|
||||||
/// Windows: LIBNAME-MAJOR-MINOR.dll
|
/// Windows: LIBNAME-MAJOR-MINOR-PATCH.dll
|
||||||
/// Linux: libLIBNAME.so.MAJOR.MINOR
|
/// Linux: libLIBNAME.so.MAJOR.MINOR.PATCH
|
||||||
/// Mac: libLIBNAME.MAJOR.MINOR.dylib
|
/// Mac: libLIBNAME.MAJOR.MINOR.PATCH.dylib
|
||||||
static std::string GetVersionedFilename(const char* libname, int major = -1, int minor = -1);
|
static std::string GetVersionedFilename(const char* libname, int major = -1, int minor = -1, int patch = -1);
|
||||||
|
|
||||||
/// Returns true if a module is loaded, otherwise false.
|
/// Returns true if a module is loaded, otherwise false.
|
||||||
bool IsOpen() const { return m_handle != nullptr; }
|
bool IsOpen() const { return m_handle != nullptr; }
|
||||||
|
|
Loading…
Reference in a new issue