[Cmake-commits] CMake branch, master, updated. 018c13ff73d9b7b151cb77f7adcbbb7be27f49d3

cmake-commits at cmake.org cmake-commits at cmake.org
Fri Apr 9 12:20:08 EDT 2010


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, master has been updated
       via  018c13ff73d9b7b151cb77f7adcbbb7be27f49d3 (commit)
      from  f468b50e9a3d34682cf8e7d24c77ac2fc816ca24 (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 -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=018c13ff73d9b7b151cb77f7adcbbb7be27f49d3
commit 018c13ff73d9b7b151cb77f7adcbbb7be27f49d3
Author: David Cole <David.Cole at kitware.com>
Date:   Fri Apr 9 12:15:06 2010 -0400

    Patch to avoid short name usage where possible. Get the actual case spelling of a file name on 'Windows' without converting to short name and back again. Avoids bad behavior reported in http://bugs.winehq.org/show_bug.cgi?id=22286 when using cmake under a wine/msys/mingw installation on a Linux box. Thanks to Clinton Stimpson for preparing the patch.

diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index 1c00621..9ab0fdf 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -3065,38 +3065,35 @@ kwsys_stl::string SystemTools::RelativePath(const char* local, const char* remot
   return relativePath;
 }
 
-// OK, some fun stuff to get the actual case of a given path.
-// Basically, you just need to call ShortPath, then GetLongPathName,
-// However, GetLongPathName is not implemented on windows NT and 95,
-// so we have to simulate it on those versions
 #ifdef _WIN32
-int OldWindowsGetLongPath(kwsys_stl::string const& shortPath,
-                          kwsys_stl::string& longPath  )
+static int GetCasePathName(const kwsys_stl::string & pathIn,
+                            kwsys_stl::string & casePath)
 {
-  kwsys_stl::string::size_type iFound = shortPath.rfind('/');
-  if (iFound > 1  && iFound != shortPath.npos)
+  kwsys_stl::string::size_type iFound = pathIn.rfind('/');
+  if (iFound > 1  && iFound != pathIn.npos)
     {
     // recurse to peel off components
     //
-    if (OldWindowsGetLongPath(shortPath.substr(0, iFound), longPath) > 0)
+    if (GetCasePathName(pathIn.substr(0, iFound), casePath) > 0)
       {
-      longPath += '/';
-      if (shortPath[1] != '/')
+      casePath += '/';
+      if (pathIn[1] != '/')
         {
         WIN32_FIND_DATA findData;
 
         // append the long component name to the path
         //
-        if (INVALID_HANDLE_VALUE != ::FindFirstFile
-            (shortPath.c_str(), &findData))
+        HANDLE hFind = ::FindFirstFile(pathIn.c_str(), &findData);
+        if (INVALID_HANDLE_VALUE != hFind)
           {
-          longPath += findData.cFileName;
+          casePath += findData.cFileName;
+          ::FindClose(hFind);
           }
         else
           {
           // if FindFirstFile fails, return the error code
           //
-          longPath = "";
+          casePath = "";
           return 0;
           }
         }
@@ -3104,37 +3101,9 @@ int OldWindowsGetLongPath(kwsys_stl::string const& shortPath,
     }
   else
     {
-    longPath = shortPath;
+    casePath = pathIn;
     }
-  return (int)longPath.size();
-}
-
-
-int PortableGetLongPathName(const char* pathIn,
-                            kwsys_stl::string & longPath)
-{ 
-  HMODULE lh = LoadLibrary("Kernel32.dll");
-  if(lh)
-    {
-    FARPROC proc =  GetProcAddress(lh, "GetLongPathNameA");
-    if(proc)
-      {
-      typedef  DWORD (WINAPI * GetLongFunctionPtr) (LPCSTR,LPSTR,DWORD); 
-      GetLongFunctionPtr func = (GetLongFunctionPtr)proc;
-      char buffer[MAX_PATH+1];
-      int len = (*func)(pathIn, buffer, MAX_PATH+1);
-      if(len == 0 || len > MAX_PATH+1)
-        {
-        FreeLibrary(lh);
-        return 0;
-        }
-      longPath = buffer;
-      FreeLibrary(lh);
-      return len;
-      }
-    FreeLibrary(lh);
-    }
-  return OldWindowsGetLongPath(pathIn, longPath);
+  return (int)casePath.size();
 }
 #endif
 
@@ -3153,29 +3122,19 @@ kwsys_stl::string SystemTools::GetActualCaseForPath(const char* p)
     {
     return i->second;
     }
-  kwsys_stl::string shortPath;
-  if(!SystemTools::GetShortPath(p, shortPath))
-    {
-    return p;
-    }
-  kwsys_stl::string longPath;
-  int len = PortableGetLongPathName(shortPath.c_str(), longPath);
+  kwsys_stl::string casePath;
+  int len = GetCasePathName(p, casePath);
   if(len == 0 || len > MAX_PATH+1)
     {
     return p;
     }
-  // Use original path if conversion back to a long path failed.
-  if(longPath == shortPath)
-    {
-    longPath = p;
-    }
   // make sure drive letter is always upper case
-  if(longPath.size() > 1 && longPath[1] == ':')
+  if(casePath.size() > 1 && casePath[1] == ':')
     {
-    longPath[0] = toupper(longPath[0]);
+    casePath[0] = toupper(casePath[0]);
     }
-  (*SystemTools::LongPathMap)[p] = longPath;
-  return longPath;
+  (*SystemTools::LongPathMap)[p] = casePath;
+  return casePath;
 #endif  
 }
 

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

Summary of changes:
 Source/kwsys/SystemTools.cxx |   81 ++++++++++-------------------------------
 1 files changed, 20 insertions(+), 61 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list