summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorJoachim Lingner <jl@openoffice.org>2011-03-01 10:55:20 +0100
committerJoachim Lingner <jl@openoffice.org>2011-03-01 10:55:20 +0100
commitfd56d52ca4db7df1b0f148dd5726cfb8e77c3ec4 (patch)
treea7fcf015268bb150707da22965febb45f1049a21 /sal
parent7a720e0ee385266bc05c0f02d507d728edec4d66 (diff)
jl164 #i109096# osl_loadModules did not work with long paths.
Diffstat (limited to 'sal')
-rw-r--r--sal/osl/w32/module.cxx21
1 files changed, 21 insertions, 0 deletions
diff --git a/sal/osl/w32/module.cxx b/sal/osl/w32/module.cxx
index b730bd3347df..e628c8b9614c 100644
--- a/sal/osl/w32/module.cxx
+++ b/sal/osl/w32/module.cxx
@@ -65,10 +65,31 @@ oslModule SAL_CALL osl_loadModule(rtl_uString *strModuleName, sal_Int32 nRtldMod
rtl_uString_assign(&Module, strModuleName);
hInstance = LoadLibraryW(reinterpret_cast<LPCWSTR>(Module->buffer));
+
if (hInstance == NULL)
hInstance = LoadLibraryExW(reinterpret_cast<LPCWSTR>(Module->buffer), NULL,
LOAD_WITH_ALTERED_SEARCH_PATH);
+ //In case of long path names (\\?\c:\...) try to shorten the filename.
+ //LoadLibrary cannot handle file names which exceed 260 letters.
+ if (hInstance == NULL && GetLastError() == ERROR_FILENAME_EXCED_RANGE)
+ {
+ wchar_t * buff = new wchar_t[Module->length + 1];
+ DWORD len = GetShortPathNameW(reinterpret_cast<LPCWSTR>(Module->buffer),
+ buff, Module->length + 1);
+ if (len )
+ {
+ hInstance = LoadLibraryW(buff);
+
+ if (hInstance == NULL)
+ hInstance = LoadLibraryExW(buff, NULL,
+ LOAD_WITH_ALTERED_SEARCH_PATH);
+
+ }
+ delete[] buff;
+ }
+
+
if (hInstance <= (HINSTANCE)HINSTANCE_ERROR)
hInstance = 0;