mirror of
https://github.com/Kitware/CMake.git
synced 2026-08-03 06:10:28 +00:00
cmFindPackageCommand: Deduplicate code to exclude . and .. dir entries
This commit is contained in:
@@ -2152,6 +2152,7 @@ public:
|
||||
|
||||
protected:
|
||||
bool Consider(std::string const& fullPath, cmFileList& listing);
|
||||
static bool IsIgnoredEntry(const char* fname);
|
||||
|
||||
private:
|
||||
bool Search(cmFileList&);
|
||||
@@ -2236,6 +2237,12 @@ bool cmFileListGeneratorBase::Consider(std::string const& fullPath,
|
||||
return listing.Visit(fullPath + '/');
|
||||
}
|
||||
|
||||
bool cmFileListGeneratorBase::IsIgnoredEntry(const char* const fname)
|
||||
{
|
||||
assert(fname != nullptr);
|
||||
return strcmp(fname, ".") == 0 || strcmp(fname, "..") == 0;
|
||||
}
|
||||
|
||||
class cmFileListGeneratorFixed : public cmFileListGeneratorBase
|
||||
{
|
||||
public:
|
||||
@@ -2330,7 +2337,7 @@ private:
|
||||
d.Load(parent);
|
||||
for (unsigned long i = 0; i < d.GetNumberOfFiles(); ++i) {
|
||||
const char* fname = d.GetFile(i);
|
||||
if (strcmp(fname, ".") == 0 || strcmp(fname, "..") == 0) {
|
||||
if (this->IsIgnoredEntry(fname)) {
|
||||
continue;
|
||||
}
|
||||
for (std::string const& n : this->Names) {
|
||||
@@ -2386,7 +2393,7 @@ private:
|
||||
d.Load(parent);
|
||||
for (unsigned long i = 0; i < d.GetNumberOfFiles(); ++i) {
|
||||
const char* fname = d.GetFile(i);
|
||||
if (strcmp(fname, ".") == 0 || strcmp(fname, "..") == 0) {
|
||||
if (this->IsIgnoredEntry(fname)) {
|
||||
continue;
|
||||
}
|
||||
for (std::string name : this->Names) {
|
||||
@@ -2433,7 +2440,7 @@ private:
|
||||
d.Load(parent);
|
||||
for (unsigned long i = 0; i < d.GetNumberOfFiles(); ++i) {
|
||||
const char* fname = d.GetFile(i);
|
||||
if (strcmp(fname, ".") == 0 || strcmp(fname, "..") == 0) {
|
||||
if (this->IsIgnoredEntry(fname)) {
|
||||
continue;
|
||||
}
|
||||
if (cmsysString_strcasecmp(fname, this->String.c_str()) == 0) {
|
||||
|
||||
Reference in New Issue
Block a user