add SharedLibrary::getOSName() to improve portability of shared library

real filename over different OS like Linux/Unix/Cygwin & Windows.

Signed-off-by: FrancisANDRE <zosrothko@orange.fr>
This commit is contained in:
FrancisANDRE
2015-09-19 08:28:26 +02:00
parent b2ef29528d
commit a4479552b6
4 changed files with 12 additions and 3 deletions

View File

@@ -121,7 +121,7 @@ public:
static std::string prefix(); static std::string prefix();
/// Returns the platform-specific filename prefix /// Returns the platform-specific filename prefix
/// for shared libraries. /// for shared libraries.
/// Most platforms would return an empty string, but /// Most platforms would return "lib" as prefix, while
/// on Cygwin, the "cyg" prefix will be returned. /// on Cygwin, the "cyg" prefix will be returned.
static std::string suffix(); static std::string suffix();
@@ -130,6 +130,11 @@ public:
/// In debug mode, the suffix also includes a /// In debug mode, the suffix also includes a
/// "d" to specify the debug version of a library. /// "d" to specify the debug version of a library.
static std::string getOSName(const std::string& name);
/// Returns the platform-specific filename
/// for shared libraries by prefixing and suffixing name
/// with prefix() and suffix()
private: private:
SharedLibrary(const SharedLibrary&); SharedLibrary(const SharedLibrary&);
SharedLibrary& operator = (const SharedLibrary&); SharedLibrary& operator = (const SharedLibrary&);

View File

@@ -115,5 +115,9 @@ std::string SharedLibrary::suffix()
return suffixImpl(); return suffixImpl();
} }
std::string SharedLibrary::getOSName(const std::string& name)
{
return prefix() + name + suffix();
}
} // namespace Poco } // namespace Poco

View File

@@ -85,7 +85,7 @@ const std::string& SharedLibraryImpl::getPathImpl() const
std::string SharedLibraryImpl::prefixImpl() std::string SharedLibraryImpl::prefixImpl()
{ {
return ""; return "lib";
} }

View File

@@ -104,7 +104,7 @@ std::string SharedLibraryImpl::prefixImpl()
#if POCO_OS == POCO_OS_CYGWIN #if POCO_OS == POCO_OS_CYGWIN
return "cyg"; return "cyg";
#else #else
return ""; return "lib";
#endif #endif
} }