[PATCH] D12711: ScanDirForExecutable on Windows fails to find executables with the "exe" extension in name
Oleg Ranevskyy via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 9 07:19:38 PDT 2015
iid_iunknown updated this revision to Diff 34329.
iid_iunknown added a comment.
The patch updated according to the Reid's remarks. File extensions are now handled by sys::fs::can_execute.
Repository:
rL LLVM
http://reviews.llvm.org/D12711
Files:
include/llvm/Support/FileSystem.h
lib/Support/Unix/Path.inc
lib/Support/Windows/Path.inc
Index: lib/Support/Windows/Path.inc
===================================================================
--- lib/Support/Windows/Path.inc
+++ lib/Support/Windows/Path.inc
@@ -17,6 +17,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/WindowsError.h"
#include <fcntl.h>
#include <io.h>
@@ -302,6 +303,21 @@
return std::error_code();
}
+bool can_execute(const Twine &Path) {
+ SmallVector<StringRef, 12> PathExts;
+ PathExts.push_back("");
+ PathExts.push_back(".exe"); // FIXME: This must be in %PATHEXT%.
+ if (const char *PathExtEnv = std::getenv("PATHEXT"))
+ SplitString(PathExtEnv, PathExts, ";");
+
+ for (StringRef Ext : PathExts) {
+ if (!access(Path + Ext, AccessMode::Execute))
+ return true;
+ }
+
+ return false;
+}
+
bool equivalent(file_status A, file_status B) {
assert(status_known(A) && status_known(B));
return A.FileIndexHigh == B.FileIndexHigh &&
Index: lib/Support/Unix/Path.inc
===================================================================
--- lib/Support/Unix/Path.inc
+++ lib/Support/Unix/Path.inc
@@ -325,6 +325,10 @@
return std::error_code();
}
+bool can_execute(const Twine &Path) {
+ return !access(Path, AccessMode::Execute);
+}
+
bool equivalent(file_status A, file_status B) {
assert(status_known(A) && status_known(B));
return A.fs_st_dev == B.fs_st_dev &&
Index: include/llvm/Support/FileSystem.h
===================================================================
--- include/llvm/Support/FileSystem.h
+++ include/llvm/Support/FileSystem.h
@@ -378,9 +378,7 @@
///
/// @param Path Input path.
/// @returns True if we can execute it, false otherwise.
-inline bool can_execute(const Twine &Path) {
- return !access(Path, AccessMode::Execute);
-}
+bool can_execute(const Twine &Path);
/// @brief Can we write this file?
///
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12711.34329.patch
Type: text/x-patch
Size: 1998 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150909/dc58c06d/attachment.bin>
More information about the llvm-commits
mailing list