| Index: base/files/file_util_posix.cc
|
| diff --git a/base/files/file_util_posix.cc b/base/files/file_util_posix.cc
|
| index ca1c5250b920d310e0be12acb2a73a5cede3bddc..42de9316f1c9b02aa803feb8113c6a03d958e5c7 100644
|
| --- a/base/files/file_util_posix.cc
|
| +++ b/base/files/file_util_posix.cc
|
| @@ -22,6 +22,7 @@
|
| #include <time.h>
|
| #include <unistd.h>
|
|
|
| +#include "base/environment.h"
|
| #include "base/files/file_enumerator.h"
|
| #include "base/files/file_path.h"
|
| #include "base/files/scoped_file.h"
|
| @@ -31,6 +32,7 @@
|
| #include "base/path_service.h"
|
| #include "base/posix/eintr_wrapper.h"
|
| #include "base/stl_util.h"
|
| +#include "base/strings/string_split.h"
|
| #include "base/strings/string_util.h"
|
| #include "base/strings/stringprintf.h"
|
| #include "base/strings/sys_string_conversions.h"
|
| @@ -455,6 +457,25 @@ bool SetPosixFilePermissions(const FilePath& path,
|
| return true;
|
| }
|
|
|
| +bool ExecutableExistsInPath(Environment* env,
|
| + const FilePath::StringType& executable) {
|
| + std::string path;
|
| + if (!env->GetVar("PATH", &path)) {
|
| + LOG(ERROR) << "No $PATH variable. Assuming no " << executable << ".";
|
| + return false;
|
| + }
|
| +
|
| + for (const StringPiece& cur_path :
|
| + SplitStringPiece(path, ":", KEEP_WHITESPACE, SPLIT_WANT_NONEMPTY)) {
|
| + FilePath file(cur_path);
|
| + int permissions;
|
| + if (GetPosixFilePermissions(file.Append(executable), &permissions) &&
|
| + (permissions & FILE_PERMISSION_EXECUTE_BY_USER))
|
| + return true;
|
| + }
|
| + return false;
|
| +}
|
| +
|
| #if !defined(OS_MACOSX)
|
| // This is implemented in file_util_mac.mm for Mac.
|
| bool GetTempDir(FilePath* path) {
|
|
|