node-pty 1.1.0-beta24 → 1.1.0-beta25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/win/path_util.cc +23 -24
package/package.json
CHANGED
package/src/win/path_util.cc
CHANGED
|
@@ -58,38 +58,37 @@ std::wstring get_shell_path(std::wstring filename) {
|
|
|
58
58
|
return shellpath;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
wchar_t buffer_[MAX_ENV];
|
|
61
|
+
wchar_t* buffer_ = new wchar_t[MAX_ENV];
|
|
62
62
|
int read = ::GetEnvironmentVariableW(L"Path", buffer_, MAX_ENV);
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
paths.push_back(buffer.substr(0, pos));
|
|
73
|
-
buffer.erase(0, pos + delimiter.length());
|
|
74
|
-
}
|
|
63
|
+
if (read) {
|
|
64
|
+
std::wstring delimiter = L";";
|
|
65
|
+
size_t pos = 0;
|
|
66
|
+
std::vector<std::wstring> paths;
|
|
67
|
+
std::wstring buffer(buffer_);
|
|
68
|
+
while ((pos = buffer.find(delimiter)) != std::wstring::npos) {
|
|
69
|
+
paths.push_back(buffer.substr(0, pos));
|
|
70
|
+
buffer.erase(0, pos + delimiter.length());
|
|
71
|
+
}
|
|
75
72
|
|
|
76
|
-
|
|
73
|
+
const wchar_t *filename_ = filename.c_str();
|
|
77
74
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
75
|
+
for (size_t i = 0; i < paths.size(); ++i) {
|
|
76
|
+
std::wstring path = paths[i];
|
|
77
|
+
wchar_t searchPath[MAX_PATH];
|
|
78
|
+
::PathCombineW(searchPath, const_cast<wchar_t*>(path.c_str()), filename_);
|
|
82
79
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
80
|
+
if (searchPath == NULL) {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
86
83
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
if (file_exists(searchPath)) {
|
|
85
|
+
shellpath = searchPath;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
90
88
|
}
|
|
91
89
|
}
|
|
92
90
|
|
|
91
|
+
delete[] buffer_;
|
|
93
92
|
return shellpath;
|
|
94
93
|
}
|
|
95
94
|
|