[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 12:44:57 PDT 2015


iid_iunknown updated this revision to Diff 34360.
iid_iunknown added a comment.

sys::fs::can_execute now ignores PATHEXT similarly to ExecuteAndWait. The "exe" extension is used only.


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
@@ -302,6 +302,11 @@
   return std::error_code();
 }
 
+bool can_execute(const Twine &Path) {
+  return !access(Path, AccessMode::Execute) ||
+         !access(Path + ".exe", AccessMode::Execute);
+}
+
 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.34360.patch
Type: text/x-patch
Size: 1467 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150909/ea1bbc26/attachment.bin>


More information about the llvm-commits mailing list