58 lines
2.2 KiB
Diff
58 lines
2.2 KiB
Diff
From 637232e0b57941d7dfa1d9646b28c0f0111a5f7c Mon Sep 17 00:00:00 2001
|
|
From: martell <martellmalone@gmail.com>
|
|
Date: Mon, 15 Sep 2014 01:02:08 +0100
|
|
Subject: [PATCH 2/3] Add support for conversion of all argv path args
|
|
|
|
---
|
|
unix-adapter/main.cc | 21 ++++-----------------
|
|
1 file changed, 4 insertions(+), 17 deletions(-)
|
|
|
|
diff --git a/unix-adapter/main.cc b/unix-adapter/main.cc
|
|
index bd9281f..17e978f 100644
|
|
--- a/unix-adapter/main.cc
|
|
+++ b/unix-adapter/main.cc
|
|
@@ -222,28 +222,15 @@ static void setFdNonBlock(int fd)
|
|
static std::string convertPosixPathToWin(const std::string &path)
|
|
{
|
|
char *tmp;
|
|
-#if !defined(__MSYS__) && CYGWIN_VERSION_API_MINOR >= 181
|
|
ssize_t newSize = cygwin_conv_path(CCP_POSIX_TO_WIN_A | CCP_RELATIVE,
|
|
path.c_str(), NULL, 0);
|
|
assert(newSize >= 0);
|
|
tmp = new char[newSize + 1];
|
|
ssize_t success = cygwin_conv_path(CCP_POSIX_TO_WIN_A | CCP_RELATIVE,
|
|
path.c_str(), tmp, newSize + 1);
|
|
- assert(success == 0);
|
|
-#else
|
|
- // In the current Cygwin header file, this API is documented as deprecated
|
|
- // because it's restricted to paths of MAX_PATH length. In the CVS version
|
|
- // of MSYS, the newer API doesn't exist, and this older API is implemented
|
|
- // using msys_p2w, which seems like it would handle paths larger than
|
|
- // MAX_PATH, but there's no way to query how large the new path is.
|
|
- // Hopefully, this is large enough.
|
|
- tmp = new char[MAX_PATH + path.size()];
|
|
- cygwin_conv_to_win32_path(path.c_str(), tmp);
|
|
-#endif
|
|
- for (int i = 0; tmp[i] != '\0'; ++i) {
|
|
- if (tmp[i] == '/')
|
|
- tmp[i] = '\\';
|
|
- }
|
|
+
|
|
+ if(success) return path;
|
|
+
|
|
std::string ret(tmp);
|
|
delete [] tmp;
|
|
return ret;
|
|
@@ -359,7 +346,7 @@ int main(int argc, char *argv[])
|
|
std::vector<std::string> argVector;
|
|
argVector.push_back(convertPosixPathToWin(argv[1]));
|
|
for (int i = 2; i < argc; ++i)
|
|
- argVector.push_back(argv[i]);
|
|
+ argVector.push_back(convertPosixPathToWin(argv[i]));
|
|
std::string cmdLine = argvToCommandLine(argVector);
|
|
wchar_t *cmdLineW = heapMbsToWcs(cmdLine.c_str());
|
|
int ret = winpty_start_process(winpty,
|
|
--
|
|
2.1.0
|
|
|