mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-12 10:13:51 +01:00
added SharedLibrary::setSearchPath()
This commit is contained in:
parent
df4cb29ea5
commit
325cfcb3c2
@ -122,6 +122,16 @@ public:
|
||||
/// (e.g., "d.so", "d.dll") unless the library has
|
||||
/// been compiled with -DPOCO_NO_SHARED_LIBRARY_DEBUG_SUFFIX.
|
||||
|
||||
static bool setSearchPath(const std::string& path);
|
||||
/// Adds the given path to the list of paths shared libraries
|
||||
/// are searched in.
|
||||
///
|
||||
/// Returns true if the path was set, otherwise false.
|
||||
///
|
||||
/// Currently only supported on Windows, where it calls
|
||||
/// SetDllDirectory(). On all other platforms, does not
|
||||
/// do anything and returns false.
|
||||
|
||||
private:
|
||||
SharedLibrary(const SharedLibrary&);
|
||||
SharedLibrary& operator = (const SharedLibrary&);
|
||||
|
@ -37,6 +37,7 @@ protected:
|
||||
void* findSymbolImpl(const std::string& name);
|
||||
const std::string& getPathImpl() const;
|
||||
static std::string suffixImpl();
|
||||
static bool setSearchPathImpl(const std::string& path);
|
||||
|
||||
private:
|
||||
std::string _path;
|
||||
|
@ -31,7 +31,7 @@ protected:
|
||||
enum Flags
|
||||
{
|
||||
SHLIB_GLOBAL_IMPL = 1,
|
||||
SHLIB_LOCAL_IMPL = 2
|
||||
SHLIB_LOCAL_IMPL = 2
|
||||
};
|
||||
|
||||
SharedLibraryImpl();
|
||||
@ -42,6 +42,7 @@ protected:
|
||||
void* findSymbolImpl(const std::string& name);
|
||||
const std::string& getPathImpl() const;
|
||||
static std::string suffixImpl();
|
||||
static bool setSearchPathImpl(const std::string& path);
|
||||
|
||||
private:
|
||||
std::string _path;
|
||||
|
@ -37,6 +37,7 @@ protected:
|
||||
void* findSymbolImpl(const std::string& name);
|
||||
const std::string& getPathImpl() const;
|
||||
static std::string suffixImpl();
|
||||
static bool setSearchPathImpl(const std::string& path);
|
||||
|
||||
private:
|
||||
std::string _path;
|
||||
|
@ -36,6 +36,7 @@ protected:
|
||||
void* findSymbolImpl(const std::string& name);
|
||||
const std::string& getPathImpl() const;
|
||||
static std::string suffixImpl();
|
||||
static bool setSearchPathImpl(const std::string& path);
|
||||
|
||||
private:
|
||||
std::string _path;
|
||||
|
@ -36,6 +36,7 @@ protected:
|
||||
void* findSymbolImpl(const std::string& name);
|
||||
const std::string& getPathImpl() const;
|
||||
static std::string suffixImpl();
|
||||
static bool setSearchPathImpl(const std::string& path);
|
||||
|
||||
private:
|
||||
std::string _path;
|
||||
|
@ -106,4 +106,10 @@ std::string SharedLibrary::suffix()
|
||||
}
|
||||
|
||||
|
||||
bool SharedLibrary::setSearchPath(const std::string& path)
|
||||
{
|
||||
return setSearchPathImpl(path);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
@ -59,7 +59,7 @@ void SharedLibraryImpl::unloadImpl()
|
||||
|
||||
bool SharedLibraryImpl::isLoadedImpl() const
|
||||
{
|
||||
return _handle != 0;
|
||||
return _handle != 0;
|
||||
}
|
||||
|
||||
|
||||
@ -91,4 +91,10 @@ std::string SharedLibraryImpl::suffixImpl()
|
||||
}
|
||||
|
||||
|
||||
bool SharedLibraryImpl::setSearchPathImpl(const std::string&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
@ -74,7 +74,7 @@ void SharedLibraryImpl::unloadImpl()
|
||||
|
||||
bool SharedLibraryImpl::isLoadedImpl() const
|
||||
{
|
||||
return _handle != 0;
|
||||
return _handle != 0;
|
||||
}
|
||||
|
||||
|
||||
@ -127,4 +127,10 @@ std::string SharedLibraryImpl::suffixImpl()
|
||||
}
|
||||
|
||||
|
||||
bool SharedLibraryImpl::setSearchPathImpl(const std::string&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
@ -99,14 +99,14 @@ void SharedLibraryImpl::unloadImpl()
|
||||
|
||||
bool SharedLibraryImpl::isLoadedImpl() const
|
||||
{
|
||||
return _moduleId != 0;
|
||||
return _moduleId != 0;
|
||||
}
|
||||
|
||||
|
||||
void* SharedLibraryImpl::findSymbolImpl(const std::string& name)
|
||||
{
|
||||
poco_assert (_moduleId != 0);
|
||||
|
||||
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
|
||||
MODULE_INFO mi;
|
||||
@ -132,4 +132,10 @@ std::string SharedLibraryImpl::suffixImpl()
|
||||
}
|
||||
|
||||
|
||||
bool SharedLibraryImpl::setSearchPathImpl(const std::string&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
@ -63,7 +63,7 @@ void SharedLibraryImpl::unloadImpl()
|
||||
|
||||
bool SharedLibraryImpl::isLoadedImpl() const
|
||||
{
|
||||
return _handle != 0;
|
||||
return _handle != 0;
|
||||
}
|
||||
|
||||
|
||||
@ -95,4 +95,14 @@ std::string SharedLibraryImpl::suffixImpl()
|
||||
}
|
||||
|
||||
|
||||
bool SharedLibraryImpl::setSearchPathImpl(const std::string& path)
|
||||
{
|
||||
#if _WIN32_WINNT >= 0x0502
|
||||
return SetDllDirectoryA(path.c_str()) != 0;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
@ -68,7 +68,7 @@ void SharedLibraryImpl::unloadImpl()
|
||||
|
||||
bool SharedLibraryImpl::isLoadedImpl() const
|
||||
{
|
||||
return _handle != 0;
|
||||
return _handle != 0;
|
||||
}
|
||||
|
||||
|
||||
@ -106,4 +106,16 @@ std::string SharedLibraryImpl::suffixImpl()
|
||||
}
|
||||
|
||||
|
||||
bool SharedLibraryImpl::setSearchPathImpl(const std::string& path)
|
||||
{
|
||||
#if _WIN32_WINNT >= 0x0502
|
||||
std::wstring wpath;
|
||||
Poco::UnicodeConverter::toUTF16(path, wpath);
|
||||
return SetDllDirectoryW(wpath.c_str()) != 0;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
Loading…
Reference in New Issue
Block a user