Browse Source

Merge branch 'upstream-KWSys' into update-kwsys

* upstream-KWSys:
  KWSys 2017-02-06 (ef673998)
Brad King 8 years ago
parent
commit
c2645e1979
3 changed files with 28 additions and 1 deletions
  1. 1 1
      Source/kwsys/CMakeLists.txt
  2. 22 0
      Source/kwsys/SystemTools.cxx
  3. 5 0
      Source/kwsys/SystemTools.hxx.in

+ 1 - 1
Source/kwsys/CMakeLists.txt

@@ -946,7 +946,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
         testConsoleBuf
         )
       IF("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC" AND
-         NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "19.0")
+         CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "19.0.23506")
         set_property(SOURCE testConsoleBuf.cxx testConsoleBufChild.cxx PROPERTY COMPILE_FLAGS /utf-8)
       ENDIF()
       SET_PROPERTY(SOURCE testConsoleBuf.cxx APPEND PROPERTY COMPILE_DEFINITIONS

+ 22 - 0
Source/kwsys/SystemTools.cxx

@@ -3067,6 +3067,28 @@ bool SystemTools::FileIsSymlink(const std::string& name)
 #endif
 }
 
+bool SystemTools::FileIsFIFO(const std::string& name)
+{
+#if defined(_WIN32)
+  HANDLE hFile =
+    CreateFileW(Encoding::ToWide(name).c_str(), GENERIC_READ, FILE_SHARE_READ,
+                NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
+  if (hFile == INVALID_HANDLE_VALUE) {
+    return false;
+  }
+  const DWORD type = GetFileType(hFile);
+  CloseHandle(hFile);
+  return type == FILE_TYPE_PIPE;
+#else
+  struct stat fs;
+  if (lstat(name.c_str(), &fs) == 0) {
+    return S_ISFIFO(fs.st_mode);
+  } else {
+    return false;
+  }
+#endif
+}
+
 #if defined(_WIN32) && !defined(__CYGWIN__)
 bool SystemTools::CreateSymlink(const std::string&, const std::string&)
 {

+ 5 - 0
Source/kwsys/SystemTools.hxx.in

@@ -653,6 +653,11 @@ public:
    */
   static bool FileIsSymlink(const std::string& name);
 
+  /**
+   * Return true if the file is a FIFO
+   */
+  static bool FileIsFIFO(const std::string& name);
+
   /**
    * Return true if the file has a given signature (first set of bytes)
    */