From 2c5b3e7764d7d3213d3448c3c6c424a19d0c837c Mon Sep 17 00:00:00 2001 From: Jürgen Schmidt Date: Tue, 10 Jun 2014 13:18:31 +0000 Subject: Resolves: #i122368# convert inc paths into short form on windows... to avoid problem with ucpp (cherry picked from commit 6e370ddd6b532e7bf12df3aa52f93913f4ea8348) Conflicts: idlc/source/options.cxx Change-Id: Ia8c7dc3a9a7df68a483dd106cd47c8624952aeae --- idlc/source/options.cxx | 52 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) (limited to 'idlc/source') diff --git a/idlc/source/options.cxx b/idlc/source/options.cxx index c04603d118b7..9a15ea795ca9 100644 --- a/idlc/source/options.cxx +++ b/idlc/source/options.cxx @@ -24,6 +24,28 @@ #include #include +#include "rtl/ustring.hxx" +#include "osl/file.hxx" + +#ifdef WNT +# include +#endif + +/* +#ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# ifdef _MSC_VER +# pragma warning(push,1) +# endif +# include +# ifdef _MSC_VER +# pragma warning(pop) +# endif +# include +# undef WIN32_LEAN_AND_MEAN +#endif +*/ + #include #include @@ -169,6 +191,29 @@ bool Options::setOption(char const * option, std::string const & rArg) return (result); } +#ifdef WNT +/* Helper functiopn to convert windows paths including spaces, brackets etc. into + a windows short Url. The ucpp preprocessor has problems with such paths and returns + with error. +*/ +OString convertIncPathtoShortWindowsPath(const OString& incPath) { + OUString path = OStringToOUString(incPath, RTL_TEXTENCODING_UTF8); + + std::vector vec(path.getLength() + 1); + //GetShortPathNameW only works if the file can be found! + const DWORD len = GetShortPathNameW( + reinterpret_cast(path.getStr()), reinterpret_cast(&vec[0]), path.getLength() + 1); + + if (len > 0) + { + OUString ret(&vec[0], len); + return OUStringToOString(ret, RTL_TEXTENCODING_UTF8); + } + + return incPath; +} +#endif + bool Options::initOptions(std::vector< std::string > & rArgs) throw(IllegalArgument) { std::vector< std::string >::const_iterator first = rArgs.begin(), last = rArgs.end(); @@ -225,7 +270,12 @@ bool Options::initOptions(std::vector< std::string > & rArgs) throw(IllegalArgum if (!buffer.isEmpty()) buffer.append(' '); // buffer.append("-I\""); - buffer.append(param.getToken(0, ';', k)); +#ifdef WNT + OString incpath = convertIncPathtoShortWindowsPath(param.getToken(0, ';', k)); +#else + OString incpath = param.getToken(0, ';', k); +#endif + buffer.append(incpath); // buffer.append("\""); } while (k != -1); param = buffer.makeStringAndClear(); -- cgit