summaryrefslogtreecommitdiff
path: root/sal/osl/w32/procimpl.cxx
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2011-03-23 16:59:59 +0100
committerJan Holesovsky <kendy@suse.cz>2011-03-23 16:59:59 +0100
commit4be7cca60bc7cc0a066b7384d56624266dc0dfcf (patch)
tree990b1fda00fca6f26ff74fd29552687b4e3c37ed /sal/osl/w32/procimpl.cxx
parent79a6c0f8a28b43c36c3b02dc5e116f2d17e92ef0 (diff)
parenta24842b43a687808376f69d4bdbb45fcddde73c4 (diff)
Merge commit 'ooo/DEV300_m103'
Conflicts: codemaker/source/bonobowrappermaker/corbaoptions.cxx codemaker/source/cppumaker/cppuoptions.cxx codemaker/source/cunomaker/cunooptions.cxx codemaker/source/idlmaker/idloptions.cxx codemaker/source/javamaker/javaoptions.cxx cppu/source/typelib/typelib.cxx idlc/source/options.cxx offapi/com/sun/star/util/PathSubstitution.idl offapi/drafts/com/sun/star/form/ListEntryEvent.idl offapi/drafts/com/sun/star/form/XBindableValue.idl offapi/drafts/com/sun/star/form/XListEntryListener.idl offapi/drafts/com/sun/star/form/XListEntrySink.idl offapi/drafts/com/sun/star/form/XListEntrySource.idl offapi/drafts/com/sun/star/form/XValueBinding.idl registry/tools/checksingleton.cxx registry/tools/options.hxx registry/tools/regcompare.cxx registry/tools/regmerge.cxx sal/cppunittester/cppunittester.cxx sal/osl/unx/socket.c sal/osl/w32/diagnose.c sal/prj/d.lst sal/rtl/source/alloc_fini.cxx sal/rtl/source/alloc_global.c sal/rtl/source/makefile.mk
Diffstat (limited to 'sal/osl/w32/procimpl.cxx')
-rwxr-xr-x[-rw-r--r--]sal/osl/w32/procimpl.cxx35
1 files changed, 35 insertions, 0 deletions
diff --git a/sal/osl/w32/procimpl.cxx b/sal/osl/w32/procimpl.cxx
index 87b47fe263a5..54d5f912d0e2 100644..100755
--- a/sal/osl/w32/procimpl.cxx
+++ b/sal/osl/w32/procimpl.cxx
@@ -301,6 +301,39 @@ namespace /* private */
return quoted.makeStringAndClear();
}
+ //The parameter path must be a system path. If it is longer than 260 characters
+ //then it is shortened using the GetShortPathName function. This function only
+ //works if the path exists. Because "path" can be the path to an executable, it
+ //may not have the file extension ".exe". However, if the file on disk has the
+ //".exe" extension, then the function will fail. In this case a second attempt
+ //is started by adding the parameter "extension" to "path".
+ rtl::OUString getShortPath(rtl::OUString const & path, rtl::OUString const & extension)
+ {
+ rtl::OUString ret(path);
+ if (path.getLength() > 260)
+ {
+ std::vector<sal_Unicode, rtl::Allocator<sal_Unicode> > vec(path.getLength() + 1);
+ //GetShortPathNameW only works if the file can be found!
+ const DWORD len = GetShortPathNameW(
+ path.getStr(), &vec[0], path.getLength() + 1);
+
+ if (!len && GetLastError() == ERROR_FILE_NOT_FOUND
+ && extension.getLength())
+ {
+ const rtl::OUString extPath(path + extension);
+ std::vector<sal_Unicode, rtl::Allocator<sal_Unicode> > vec2(
+ extPath.getLength() + 1);
+ const DWORD len2 = GetShortPathNameW(
+ extPath.getStr(), &vec2[0], extPath.getLength() + 1);
+ ret = rtl::OUString(&vec2[0], len2);
+ }
+ else
+ {
+ ret = rtl::OUString(&vec[0], len);
+ }
+ }
+ return ret;
+ }
//##########################################################
// Returns the system path of the executable which can either
// be provided via the strImageName parameter or as first
@@ -327,6 +360,8 @@ namespace /* private */
if (osl_File_E_None != osl::FileBase::getSystemPathFromFileURL(exe_url, exe_path))
return rtl::OUString();
+ exe_path = getShortPath(exe_path, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".exe")));
+
if (exe_path.indexOf(' ') != -1)
exe_path = quote_string(exe_path);