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:
parent
7bb8678fc6
commit
714d2fc04b
@ -1097,6 +1097,29 @@ bool cmSystemTools::DoesFileExistWithExtensions(
|
|||||||
return false;
|
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)
|
bool cmSystemTools::cmCopyFile(const char* source, const char* destination)
|
||||||
{
|
{
|
||||||
return Superclass::CopyFileAlways(source, destination);
|
return Superclass::CopyFileAlways(source, destination);
|
||||||
|
@ -144,6 +144,14 @@ public:
|
|||||||
const char *name,
|
const char *name,
|
||||||
const std::vector<std::string>& sourceExts);
|
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,
|
static void Glob(const char *directory, const char *regexp,
|
||||||
std::vector<std::string>& files);
|
std::vector<std::string>& files);
|
||||||
static void GlobDirs(const char *fullPath, std::vector<std::string>& files);
|
static void GlobDirs(const char *fullPath, std::vector<std::string>& files);
|
||||||
|
@ -4000,29 +4000,6 @@ bool SystemTools::IsSubDirectory(const char* cSubdir, const char* cDir)
|
|||||||
return false;
|
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)
|
void SystemTools::Delay(unsigned int msec)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -659,14 +659,6 @@ public:
|
|||||||
const char *dir,
|
const char *dir,
|
||||||
kwsys_stl::string& filename_found,
|
kwsys_stl::string& filename_found,
|
||||||
int try_filename_dirs = 0);
|
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
|
/** compute the relative path from local to remote. local must
|
||||||
be a directory. remote can be a file or a directory.
|
be a directory. remote can be a file or a directory.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user