feat(util/lean_path): support LEAN_PATH that uses ':' instead of ';' on Windows
This commit is contained in:
parent
be9c59b9ff
commit
704e203cd7
1 changed files with 5 additions and 1 deletions
|
@ -41,6 +41,7 @@ bool is_directory(char const * pathname) {
|
||||||
#if defined(LEAN_WINDOWS) && !defined(LEAN_CYGWIN)
|
#if defined(LEAN_WINDOWS) && !defined(LEAN_CYGWIN)
|
||||||
// Windows version
|
// Windows version
|
||||||
static char g_path_sep = ';';
|
static char g_path_sep = ';';
|
||||||
|
static char g_path_alt_sep = ':';
|
||||||
static char g_sep = '\\';
|
static char g_sep = '\\';
|
||||||
static char g_bad_sep = '/';
|
static char g_bad_sep = '/';
|
||||||
static std::string get_exe_location() {
|
static std::string get_exe_location() {
|
||||||
|
@ -50,6 +51,7 @@ static std::string get_exe_location() {
|
||||||
std::wstring pathstr(path);
|
std::wstring pathstr(path);
|
||||||
return std::string(pathstr.begin(), pathstr.end());
|
return std::string(pathstr.begin(), pathstr.end());
|
||||||
}
|
}
|
||||||
|
bool is_path_sep(char c) { return c == g_path_sep || c == g_path_alt_sep; }
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
// OSX version
|
// OSX version
|
||||||
#include <mach-o/dyld.h>
|
#include <mach-o/dyld.h>
|
||||||
|
@ -68,6 +70,7 @@ static std::string get_exe_location() {
|
||||||
throw exception("failed to resolve symbolic links in " + std::string(buf1));
|
throw exception("failed to resolve symbolic links in " + std::string(buf1));
|
||||||
return std::string(buf2);
|
return std::string(buf2);
|
||||||
}
|
}
|
||||||
|
bool is_path_sep(char c) { return c == g_path_sep; }
|
||||||
#else
|
#else
|
||||||
// Linux version
|
// Linux version
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -89,6 +92,7 @@ static std::string get_exe_location() {
|
||||||
return std::string(dest);
|
return std::string(dest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bool is_path_sep(char c) { return c == g_path_sep; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string normalize_path(std::string f) {
|
std::string normalize_path(std::string f) {
|
||||||
|
@ -129,7 +133,7 @@ void init_lean_path() {
|
||||||
unsigned j = 0;
|
unsigned j = 0;
|
||||||
unsigned sz = g_lean_path.size();
|
unsigned sz = g_lean_path.size();
|
||||||
for (; j < sz; j++) {
|
for (; j < sz; j++) {
|
||||||
if (g_lean_path[j] == g_path_sep) {
|
if (is_path_sep(g_lean_path[j])) {
|
||||||
if (j > i)
|
if (j > i)
|
||||||
g_lean_path_vector.push_back(g_lean_path.substr(i, j - i));
|
g_lean_path_vector.push_back(g_lean_path.substr(i, j - i));
|
||||||
i = j + 1;
|
i = j + 1;
|
||||||
|
|
Loading…
Reference in a new issue