From: Christian P. <cp...@us...> - 2005-05-07 13:25:29
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16744/src/System Modified Files: SharedLibCache.h SharedLib.dl.cpp SharedLib.ltdl.cpp SharedLib.shl.cpp SharedLib.win32.cpp Log Message: - SharedLibCache now caches the Unicode file names instead of their utf8 representation. - SharedLib: use absolute paths when loading / and caching filenames. Index: SharedLibCache.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/SharedLibCache.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- SharedLibCache.h 28 Apr 2005 10:37:50 -0000 1.5 +++ SharedLibCache.h 7 May 2005 13:25:20 -0000 1.6 @@ -23,6 +23,7 @@ #include "pclasses/Trace.h" #include "pclasses/Phoenix.h" +#include "pclasses/Unicode/String.h" #include "pclasses/System/CriticalSection.h" #include <map> @@ -36,7 +37,7 @@ template <typename handle_t, typename destroyF> struct SharedLibCache { - typedef std::map<std::string, handle_t> map_t; + typedef std::map<Unicode::String, handle_t> map_t; typedef typename map_t::const_iterator iterator; SharedLibCache() @@ -56,7 +57,7 @@ _handles.clear(); } - void add(const std::string& name, handle_t handle) + void add(const Unicode::String& name, handle_t handle) { iterator i = _handles.find(name); if(i == _handles.end()) @@ -66,7 +67,7 @@ } } - iterator lookup(const std::string& name) const + iterator lookup(const Unicode::String& name) const { return _handles.find(name); } Index: SharedLib.ltdl.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/SharedLib.ltdl.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- SharedLib.ltdl.cpp 28 Apr 2005 10:37:50 -0000 1.9 +++ SharedLib.ltdl.cpp 7 May 2005 13:25:20 -0000 1.10 @@ -19,6 +19,7 @@ ***************************************************************************/ #include "pclasses/Trace.h" +#include "pclasses/System/Path.h" #include "pclasses/System/SharedLib.h" #include "SharedLibCache.h" @@ -56,13 +57,13 @@ Cache& cache = shared_lib_cache<lt_dlhandle, SharedLibCloser>(); CriticalSection::ScopedLock lck(cache.mutex); - std::string utf8name = name.utf8(); + Unicode::String absName = Path(name).absPath(); // see if we can get it from the handle cache ... - Cache::iterator i = cache.lookup(utf8name); + Cache::iterator i = cache.lookup(absName); if(i == cache.end()) { - lt_dlhandle h = lt_dlopen(utf8name.c_str() /** BindMode2Flags(mode) */ ); + lt_dlhandle h = lt_dlopen(absName.utf8().c_str() /** BindMode2Flags(mode) */ ); if(!h) throw SystemError(errno, lt_dlerror(), P_SOURCEINFO); @@ -70,7 +71,7 @@ P_TRACE(SharedLib) << "library opened, handle=" << _handle; // add it to the handle cache - cache.add(utf8name, h); + cache.add(absName, h); } else { Index: SharedLib.dl.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/SharedLib.dl.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- SharedLib.dl.cpp 28 Apr 2005 10:37:50 -0000 1.11 +++ SharedLib.dl.cpp 7 May 2005 13:25:20 -0000 1.12 @@ -19,6 +19,7 @@ ***************************************************************************/ #include "pclasses/Trace.h" +#include "pclasses/System/Path.h" #include "pclasses/System/SharedLib.h" #include "SharedLibCache.h" @@ -71,20 +72,20 @@ Cache& cache = shared_lib_cache<unsigned long, SharedLibCloser>(); CriticalSection::ScopedLock lck(cache.mutex); - std::string utf8name = name.utf8(); + Unicode::String absName = Path(name).absPath(); // see if we can get it from the handle cache ... - Cache::iterator i = cache.lookup(utf8name); + Cache::iterator i = cache.lookup(absName); if(i == cache.end()) { - _handle = (unsigned long)dlopen(utf8name.c_str(), BindMode2Flags(mode)); + _handle = (unsigned long)dlopen(absName.utf8().c_str(), BindMode2Flags(mode)); if(!_handle) throw SystemError(errno, dlerror(), P_SOURCEINFO); P_TRACE(SharedLib) << "library opened, handle=" << _handle; // add it to the handle cache - cache.add(utf8name, _handle); + cache.add(absName, _handle); } else { Index: SharedLib.win32.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/SharedLib.win32.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- SharedLib.win32.cpp 28 Apr 2005 10:37:50 -0000 1.9 +++ SharedLib.win32.cpp 7 May 2005 13:25:20 -0000 1.10 @@ -19,6 +19,7 @@ ***************************************************************************/ #include "pclasses/Trace.h" +#include "pclasses/System/Path.h" #include "pclasses/System/SharedLib.h" #include "SharedLibCache.h" @@ -46,19 +47,21 @@ Cache& cache = shared_lib_cache<unsigned long, SharedLibCloser>(); CriticalSection::ScopedLock lck(cache.mutex); + Unicode::String absName = Path(name).absPath(); + // se if we can get it from the handle cache ... - Cache::iterator i = cache.lookup(name.utf8()); + Cache::iterator i = cache.lookup(absName); if(i == cache.end()) { //@fixme .. use win32 Unicode API !!! - _handle = (unsigned long)LoadLibrary(name.utf8().c_str()); + _handle = (unsigned long)LoadLibrary(absName.utf8().c_str()); if(!_handle) throw SystemError(GetLastError(), "Could not load shared library", P_SOURCEINFO); P_TRACE(SharedLib) << "library opened, handle=" << _handle; // add the handle to the cache - cache.add(name.utf8(), _handle); + cache.add(absName, _handle); } else { Index: SharedLib.shl.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/SharedLib.shl.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- SharedLib.shl.cpp 28 Apr 2005 10:37:50 -0000 1.8 +++ SharedLib.shl.cpp 7 May 2005 13:25:20 -0000 1.9 @@ -19,6 +19,7 @@ ***************************************************************************/ #include "pclasses/Trace.h" +#include "pclasses/System/Path.h" #include "pclasses/System/SharedLib.h" #include "SharedLibCache.h" @@ -64,20 +65,20 @@ Cache& cache = shared_lib_cache<unsigned long, SharedLibCloser>(); CriticalSection::ScopedLock lck(cache.mutex); - std::string utf8name = name.utf8(); + Unicode::String absName = Path(name).absPath(); // se if we have the handle cached ... - Cache::Iterator i = cache.lookup(utf8name); + Cache::Iterator i = cache.lookup(absName); if(i == cache.end()) { - _handle = (unsigned long)shl_load(utf8name.c_str(), BindMode2Flags(mode)); + _handle = (unsigned long)shl_load(absName.utf8().c_str(), BindMode2Flags(mode)); if(!_handle) throw SystemError(errno, "Error loading shared library", P_SOURCEINFO); P_TRACE(SharedLib) << "library opened, handle=" << _handle; // add the handle to the cache - cache.add(utf8name, _handle); + cache.add(absName, _handle); } else { |