From 714d2fc04ba0ba7b455ab30602aef4ebc69ecf1b Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 21 Apr 2009 11:36:59 -0400 Subject: [PATCH] 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. --- Source/cmSystemTools.cxx | 23 +++++++++++++++++++++++ Source/cmSystemTools.h | 8 ++++++++ Source/kwsys/SystemTools.cxx | 23 ----------------------- Source/kwsys/SystemTools.hxx.in | 8 -------- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 6ed45b109..d0aedd9ee 100644 --- a/Source/cmSystemTools.cxx +++ b/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); diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 7c6e3e9b6..00b4873a7 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -144,6 +144,14 @@ public: const char *name, const std::vector& 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& files); static void GlobDirs(const char *fullPath, std::vector& files); diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 2dd321355..928dc37d3 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/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 diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index 07118c2e4..31a876db8 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/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.