mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-06 06:33:24 +00:00
Make FindProgramByName return paths with slashes unmodified on Windows.
This makes its behaviour more consistent across platforms. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118048 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0f2ec15b9e
commit
9cd5971228
@ -114,7 +114,8 @@ namespace sys {
|
|||||||
|
|
||||||
/// This static constructor (factory) will attempt to locate a program in
|
/// This static constructor (factory) will attempt to locate a program in
|
||||||
/// the operating system's file system using some pre-determined set of
|
/// the operating system's file system using some pre-determined set of
|
||||||
/// locations to search (e.g. the PATH on Unix).
|
/// locations to search (e.g. the PATH on Unix). Paths with slashes are
|
||||||
|
/// returned unmodified.
|
||||||
/// @returns A Path object initialized to the path of the program or a
|
/// @returns A Path object initialized to the path of the program or a
|
||||||
/// Path object that is empty (invalid) if the program could not be found.
|
/// Path object that is empty (invalid) if the program could not be found.
|
||||||
/// @brief Construct a Program by finding it by name.
|
/// @brief Construct a Program by finding it by name.
|
||||||
|
@ -66,8 +66,8 @@ Program::FindProgramByName(const std::string& progName) {
|
|||||||
if (progName.find('/') != std::string::npos)
|
if (progName.find('/') != std::string::npos)
|
||||||
return temp;
|
return temp;
|
||||||
|
|
||||||
// At this point, the file name does not contain slashes. Search for it
|
// At this point, the file name is valid and does not contain slashes. Search
|
||||||
// through the directories specified in the PATH environment variable.
|
// for it through the directories specified in the PATH environment variable.
|
||||||
|
|
||||||
// Get the path. If its empty, we can't do anything to find it.
|
// Get the path. If its empty, we can't do anything to find it.
|
||||||
const char *PathStr = getenv("PATH");
|
const char *PathStr = getenv("PATH");
|
||||||
|
@ -67,10 +67,12 @@ Program::FindProgramByName(const std::string& progName) {
|
|||||||
Path temp;
|
Path temp;
|
||||||
if (!temp.set(progName)) // invalid name
|
if (!temp.set(progName)) // invalid name
|
||||||
return Path();
|
return Path();
|
||||||
if (temp.canExecute()) // already executable as is
|
// Return paths with slashes verbatim.
|
||||||
|
if (progName.find('\\') != std::string::npos ||
|
||||||
|
progName.find('/') != std::string::npos)
|
||||||
return temp;
|
return temp;
|
||||||
|
|
||||||
// At this point, the file name is valid and its not executable.
|
// At this point, the file name is valid and does not contain slashes.
|
||||||
// Let Windows search for it.
|
// Let Windows search for it.
|
||||||
char buffer[MAX_PATH];
|
char buffer[MAX_PATH];
|
||||||
char *dummy = NULL;
|
char *dummy = NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user