[Cmake-commits] CMake branch, next, updated. v3.6.1-1113-g144396b

Brad King brad.king at kitware.com
Thu Aug 4 10:19:18 EDT 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  144396b37723d63ddfbe3c6245adea884beb227a (commit)
       via  8abca14034c22014aead0fd4f3be737cd3835ce4 (commit)
       via  6c0820a8748e24155d3b7ce6991a90f5a396f524 (commit)
      from  448c5887d042e2cd6ce938e939602134c1a7830a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=144396b37723d63ddfbe3c6245adea884beb227a
commit 144396b37723d63ddfbe3c6245adea884beb227a
Merge: 448c588 8abca14
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Aug 4 10:19:15 2016 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu Aug 4 10:19:15 2016 -0400

    Merge topic 'update-kwsys' into next
    
    8abca140 Merge branch 'upstream-KWSys' into update-kwsys
    6c0820a8 KWSys 2016-08-03 (6d23dd7e)


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8abca14034c22014aead0fd4f3be737cd3835ce4
commit 8abca14034c22014aead0fd4f3be737cd3835ce4
Merge: 995b542 6c0820a
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Aug 4 10:11:07 2016 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu Aug 4 10:11:07 2016 -0400

    Merge branch 'upstream-KWSys' into update-kwsys
    
    * upstream-KWSys:
      KWSys 2016-08-03 (6d23dd7e)


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6c0820a8748e24155d3b7ce6991a90f5a396f524
commit 6c0820a8748e24155d3b7ce6991a90f5a396f524
Author:     KWSys Upstream <kwrobot at kitware.com>
AuthorDate: Wed Aug 3 12:32:48 2016 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu Aug 4 10:11:06 2016 -0400

    KWSys 2016-08-03 (6d23dd7e)
    
    Code extracted from:
    
        http://public.kitware.com/KWSys.git
    
    at commit 6d23dd7e455a7b2088c4ec6dce760d8243b84ee6 (master).
    
    Upstream Shortlog
    -----------------
    
    Ben Boeckel (1):
          6d23dd7e SystemTools: add a PathExists method

diff --git a/SystemTools.cxx b/SystemTools.cxx
index d479ee1..eb2bec6 100644
--- a/SystemTools.cxx
+++ b/SystemTools.cxx
@@ -1292,6 +1292,32 @@ bool SystemTools::SameFile(const std::string& file1, const std::string& file2)
 }
 
 //----------------------------------------------------------------------------
+bool SystemTools::PathExists(const std::string& path)
+{
+  if(path.empty())
+    {
+    return false;
+    }
+#if defined(__CYGWIN__)
+  // Convert path to native windows path if possible.
+  char winpath[MAX_PATH];
+  if(SystemTools::PathCygwinToWin32(path.c_str(), winpath))
+    {
+    return (GetFileAttributesA(winpath) != INVALID_FILE_ATTRIBUTES);
+    }
+  struct stat st;
+  return lstat(path.c_str(), &st) == 0;
+#elif defined(_WIN32)
+  return (GetFileAttributesW(
+            SystemTools::ConvertToWindowsExtendedPath(path).c_str())
+          != INVALID_FILE_ATTRIBUTES);
+#else
+  struct stat st;
+  return lstat(path.c_str(), &st) == 0;
+#endif
+}
+
+//----------------------------------------------------------------------------
 bool SystemTools::FileExists(const char* filename)
 {
   if(!filename)
diff --git a/SystemTools.hxx.in b/SystemTools.hxx.in
index aa1bf1b..28ff0b3 100644
--- a/SystemTools.hxx.in
+++ b/SystemTools.hxx.in
@@ -306,6 +306,11 @@ public:
   static std::string ConvertToWindowsOutputPath(const std::string&);
 
   /**
+   * Return true if a path with the given name exists in the current directory.
+   */
+  static bool PathExists(const std::string& path);
+
+  /**
    * Return true if a file exists in the current directory.
    * If isFile = true, then make sure the file is a file and
    * not a directory.  If isFile = false, then return true
diff --git a/testSystemTools.cxx b/testSystemTools.cxx
index 4dab347..9252ea6 100644
--- a/testSystemTools.cxx
+++ b/testSystemTools.cxx
@@ -204,6 +204,14 @@ static bool CheckFileOperations()
       << testNewDir << std::endl;
     res = false;
     }
+  // check existence
+  if (!kwsys::SystemTools::PathExists(testNewDir))
+    {
+    std::cerr
+      << "Problem with PathExists for: "
+      << testNewDir << std::endl;
+    res = false;
+    }
   // remove it
   if (!kwsys::SystemTools::RemoveADirectory(testNewDir))
     {
@@ -221,6 +229,15 @@ static bool CheckFileOperations()
       << testNewDir << std::endl;
     res = false;
     }
+  // check existence
+  if (kwsys::SystemTools::PathExists(testNewDir))
+    {
+    std::cerr
+      << "After RemoveADirectory: "
+      << "Problem with PathExists for: "
+      << testNewDir << std::endl;
+    res = false;
+    }
   // create it using the char* version
   if (!kwsys::SystemTools::MakeDirectory(testNewDir.c_str()))
     {
@@ -329,6 +346,31 @@ static bool CheckFileOperations()
     res = false;
     }
 
+  // calling with an empty string should return false
+  if (kwsys::SystemTools::PathExists(std::string()))
+    {
+    std::cerr
+      << "Problem with PathExists(std::string())"
+      << std::endl;
+    res = false;
+    }
+  // PathExists(x) should return true on a directory
+  if (!kwsys::SystemTools::PathExists(testNewDir))
+    {
+    std::cerr
+      << "Problem with PathExists for: "
+      << testNewDir << std::endl;
+    res = false;
+    }
+  // should work, was created as new file before
+  if (!kwsys::SystemTools::PathExists(testNewFile))
+    {
+    std::cerr
+      << "Problem with PathExists for: "
+      << testNewDir << std::endl;
+    res = false;
+    }
+
   // Reset umask
 #if defined(_WIN32) && !defined(__CYGWIN__)
   // NOTE:  Windows doesn't support toggling _S_IREAD.

-----------------------------------------------------------------------

Summary of changes:
 Source/kwsys/SystemTools.cxx     |   26 +++++++++++++++++++++++
 Source/kwsys/SystemTools.hxx.in  |    5 +++++
 Source/kwsys/testSystemTools.cxx |   42 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 73 insertions(+)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list