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.
This commit is contained in:
Brad King 2009-04-21 11:36:59 -04:00
parent 7bb8678fc6
commit 714d2fc04b
4 changed files with 31 additions and 31 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -660,14 +660,6 @@ public:
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.
Both remote and local must be full paths. Basically, if