Quellcode durchsuchen

ENH: Remove obscure method from KWSys SystemTools

This removes SystemTools::FileExistsInParentDirectories from KWSys since
it is a special-purpose method that is not generally useful.
Brad King vor 16 Jahren
Ursprung
Commit
714d2fc04b
4 geänderte Dateien mit 31 neuen und 31 gelöschten Zeilen
  1. 23 0
      Source/cmSystemTools.cxx
  2. 8 0
      Source/cmSystemTools.h
  3. 0 23
      Source/kwsys/SystemTools.cxx
  4. 0 8
      Source/kwsys/SystemTools.hxx.in

+ 23 - 0
Source/cmSystemTools.cxx

@@ -1097,6 +1097,29 @@ bool cmSystemTools::DoesFileExistWithExtensions(
   return false;
 }
 
+std::string cmSystemTools::FileExistsInParentDirectories(const char* fname,
+  const char* directory, const char* toplevel)
+{
+  std::string file = fname;
+  SystemTools::ConvertToUnixSlashes(file);
+  std::string dir = directory;
+  SystemTools::ConvertToUnixSlashes(dir);
+  while ( !dir.empty() )
+    {
+    std::string path = dir + "/" + file;
+    if ( SystemTools::FileExists(path.c_str()) )
+      {
+      return path;
+      }
+    if ( dir.size() < strlen(toplevel) )
+      {
+      break;
+      }
+    dir = SystemTools::GetParentDirectory(dir.c_str());
+    }
+  return "";
+}
+
 bool cmSystemTools::cmCopyFile(const char* source, const char* destination)
 {
   return Superclass::CopyFileAlways(source, destination);

+ 8 - 0
Source/cmSystemTools.h

@@ -144,6 +144,14 @@ public:
     const char *name,
     const std::vector<std::string>& sourceExts);
 
+  /**
+   * Check if the given file exists in one of the parent directory of the
+   * given file or directory and if it does, return the name of the file.
+   * Toplevel specifies the top-most directory to where it will look.
+   */
+  static std::string FileExistsInParentDirectories(const char* fname,
+    const char* directory, const char* toplevel);
+
   static void Glob(const char *directory, const char *regexp,
                    std::vector<std::string>& files);
   static void GlobDirs(const char *fullPath, std::vector<std::string>& files);

+ 0 - 23
Source/kwsys/SystemTools.cxx

@@ -4000,29 +4000,6 @@ bool SystemTools::IsSubDirectory(const char* cSubdir, const char* cDir)
   return false;
 }
 
-kwsys_stl::string SystemTools::FileExistsInParentDirectories(const char* fname,
-  const char* directory, const char* toplevel)
-{
-  kwsys_stl::string file = fname;
-  SystemTools::ConvertToUnixSlashes(file);
-  kwsys_stl::string dir = directory;
-  SystemTools::ConvertToUnixSlashes(dir);
-  while ( !dir.empty() )
-    {
-    kwsys_stl::string path = dir + "/" + file;
-    if ( SystemTools::FileExists(path.c_str()) )
-      {
-      return path;
-      }
-    if ( dir.size() < strlen(toplevel) )
-      {
-      break;
-      }
-    dir = SystemTools::GetParentDirectory(dir.c_str());
-    }
-  return "";
-}
-
 void SystemTools::Delay(unsigned int msec)
 {
 #ifdef _WIN32

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

@@ -659,14 +659,6 @@ public:
                               const char *dir, 
                               kwsys_stl::string& filename_found,
                               int try_filename_dirs = 0);
-  
-  /** 
-   * Check if the given file exists in one of the parent directory of the
-   * given file or directory and if it does, return the name of the file.
-   * Toplevel specifies the top-most directory to where it will look.
-   */
-  static kwsys_stl::string FileExistsInParentDirectories(const char* fname,
-    const char* directory, const char* toplevel);
 
   /** compute the relative path from local to remote.  local must 
       be a directory.  remote can be a file or a directory.