[Cmake-commits] [cmake-commits] king committed cmSystemTools.cxx 1.391 1.392 cmSystemTools.h 1.158 1.159
cmake-commits at cmake.org
cmake-commits at cmake.org
Tue Apr 21 11:37:01 EDT 2009
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv9163/Source
Modified Files:
cmSystemTools.cxx cmSystemTools.h
Log Message:
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.
Index: cmSystemTools.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSystemTools.h,v
retrieving revision 1.158
retrieving revision 1.159
diff -C 2 -d -r1.158 -r1.159
*** cmSystemTools.h 15 Apr 2009 13:57:57 -0000 1.158
--- cmSystemTools.h 21 Apr 2009 15:36:58 -0000 1.159
***************
*** 145,148 ****
--- 145,156 ----
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);
Index: cmSystemTools.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSystemTools.cxx,v
retrieving revision 1.391
retrieving revision 1.392
diff -C 2 -d -r1.391 -r1.392
*** cmSystemTools.cxx 15 Apr 2009 15:00:03 -0000 1.391
--- cmSystemTools.cxx 21 Apr 2009 15:36:58 -0000 1.392
***************
*** 1098,1101 ****
--- 1098,1124 ----
}
+ 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)
{
More information about the Cmake-commits
mailing list