summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-09-20 13:48:27 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-09-20 13:48:36 (GMT)
commit7b1e930b0f8366367c912614f6365d83f77ccd58 (patch)
tree78fae493b2de50d506033c5e2dd0eab35cae2187 /Source
parent3a210872828e14c4a9dbdcd9611504023487f19a (diff)
parentd49ea4a4d9d2efaa1321b224931ca0e5fea1cade (diff)
downloadCMake-7b1e930b0f8366367c912614f6365d83f77ccd58.zip
CMake-7b1e930b0f8366367c912614f6365d83f77ccd58.tar.gz
CMake-7b1e930b0f8366367c912614f6365d83f77ccd58.tar.bz2
Merge topic 'remove-redundant-stat'
d49ea4a4d9 Source: Remove redundant FileIsDirectory checks f5ff17fcf2 Source: Remove redundant FileIsSymlink checks Acked-by: Kitware Robot <kwrobot@kitware.com> Tested-by: buildbot <buildbot@kitware.com> Merge-request: !8810
Diffstat (limited to 'Source')
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx6
-rw-r--r--Source/cmCTest.cxx3
-rw-r--r--Source/cmFileCommand.cxx3
-rw-r--r--Source/cmInstallCommand.cxx3
-rw-r--r--Source/cmOutputRequiredFilesCommand.cxx6
-rw-r--r--Source/cmake.cxx2
-rw-r--r--Source/cmcmd.cxx12
7 files changed, 13 insertions, 22 deletions
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index e4b9239..eb3b4dd 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -1711,8 +1711,7 @@ std::string cmCTestTestHandler::FindExecutable(
// now look in the paths we specified above
for (unsigned int ai = 0; ai < attempted.size() && fullPath.empty(); ++ai) {
// first check without exe extension
- if (cmSystemTools::FileExists(attempted[ai]) &&
- !cmSystemTools::FileIsDirectory(attempted[ai])) {
+ if (cmSystemTools::FileExists(attempted[ai], true)) {
fullPath = cmSystemTools::CollapseFullPath(attempted[ai]);
resultingConfig = attemptedConfigs[ai];
}
@@ -1721,8 +1720,7 @@ std::string cmCTestTestHandler::FindExecutable(
failed.push_back(attempted[ai]);
tempPath =
cmStrCat(attempted[ai], cmSystemTools::GetExecutableExtension());
- if (cmSystemTools::FileExists(tempPath) &&
- !cmSystemTools::FileIsDirectory(tempPath)) {
+ if (cmSystemTools::FileExists(tempPath, true)) {
fullPath = cmSystemTools::CollapseFullPath(tempPath);
resultingConfig = attemptedConfigs[ai];
} else {
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 36fd3a8..b7232f3 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -1004,8 +1004,7 @@ int cmCTest::ProcessSteps()
for (kk = 0; kk < d.GetNumberOfFiles(); kk++) {
const char* file = d.GetFile(kk);
std::string fullname = notes_dir + "/" + file;
- if (cmSystemTools::FileExists(fullname) &&
- !cmSystemTools::FileIsDirectory(fullname)) {
+ if (cmSystemTools::FileExists(fullname, true)) {
if (!this->Impl->NotesFiles.empty()) {
this->Impl->NotesFiles += ";";
}
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 49a0e89..93bed9a 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -3020,8 +3020,7 @@ bool HandleCreateLinkCommand(std::vector<std::string> const& args,
}
// Check if the new file already exists and remove it.
- if ((cmSystemTools::FileExists(newFileName) ||
- cmSystemTools::FileIsSymlink(newFileName)) &&
+ if (cmSystemTools::PathExists(newFileName) &&
!cmSystemTools::RemoveFile(newFileName)) {
std::ostringstream e;
e << "Failed to create link '" << newFileName
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 7f5f15b..1b47ec4 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -1837,8 +1837,7 @@ bool HandleDirectoryMode(std::vector<std::string> const& args,
}
// Make sure the name is a directory.
- if (cmSystemTools::FileExists(dir) &&
- !cmSystemTools::FileIsDirectory(dir)) {
+ if (cmSystemTools::FileExists(dir, true)) {
status.SetError(cmStrCat(args[0], " given non-directory \"", args[i],
"\" to install."));
return false;
diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx
index 6a9a74c..75d1501 100644
--- a/Source/cmOutputRequiredFilesCommand.cxx
+++ b/Source/cmOutputRequiredFilesCommand.cxx
@@ -414,8 +414,7 @@ protected:
path += "/";
}
path += fname;
- if (cmSystemTools::FileExists(path, true) &&
- !cmSystemTools::FileIsDirectory(path)) {
+ if (cmSystemTools::FileExists(path, true)) {
std::string fp = cmSystemTools::CollapseFullPath(path);
this->DirectoryToFileToPathMap[extraPath][fname] = fp;
return fp;
@@ -428,8 +427,7 @@ protected:
path = path + "/";
}
path = path + fname;
- if (cmSystemTools::FileExists(path, true) &&
- !cmSystemTools::FileIsDirectory(path)) {
+ if (cmSystemTools::FileExists(path, true)) {
std::string fp = cmSystemTools::CollapseFullPath(path);
this->DirectoryToFileToPathMap[extraPath][fname] = fp;
return fp;
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index f7b7ada..942c59b 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -3267,7 +3267,7 @@ int cmake::CheckBuildSystem()
// If any byproduct of makefile generation is missing we must re-run.
cmList products{ mf.GetDefinition("CMAKE_MAKEFILE_PRODUCTS") };
for (auto const& p : products) {
- if (!(cmSystemTools::FileExists(p) || cmSystemTools::FileIsSymlink(p))) {
+ if (!cmSystemTools::PathExists(p)) {
if (verbose) {
cmSystemTools::Stdout(
cmStrCat("Re-run cmake, missing byproduct: ", p, '\n'));
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index 431ffbf..3dcfbf1 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -1018,8 +1018,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
// Complain if the -f option was not given and
// either file does not exist or
// file could not be removed and still exists
- bool file_exists_or_forced_remove = cmSystemTools::FileExists(arg) ||
- cmSystemTools::FileIsSymlink(arg) || force;
+ bool file_exists_or_forced_remove =
+ cmSystemTools::PathExists(arg) || force;
if (cmSystemTools::FileIsDirectory(arg)) {
if (!cmRemoveDirectory(arg, recursive)) {
return_value = 1;
@@ -1239,8 +1239,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
// supporting them.
if (args[1] == "create_symlink" && args.size() == 4) {
std::string const& destinationFileName = args[3];
- if ((cmSystemTools::FileExists(destinationFileName) ||
- cmSystemTools::FileIsSymlink(destinationFileName)) &&
+ if (cmSystemTools::PathExists(destinationFileName) &&
!cmSystemTools::RemoveFile(destinationFileName)) {
std::string emsg = cmSystemTools::GetLastSystemError();
std::cerr << "failed to create symbolic link '" << destinationFileName
@@ -1266,8 +1265,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
return 1;
}
- if ((cmSystemTools::FileExists(destinationFileName) ||
- cmSystemTools::FileIsSymlink(destinationFileName)) &&
+ if (cmSystemTools::PathExists(destinationFileName) &&
!cmSystemTools::RemoveFile(destinationFileName)) {
std::string emsg = cmSystemTools::GetLastSystemError();
std::cerr << "failed to create hard link '" << destinationFileName
@@ -1750,7 +1748,7 @@ int cmcmd::SymlinkExecutable(std::vector<std::string> const& args)
cmsys::Status cmcmd::SymlinkInternal(std::string const& file,
std::string const& link)
{
- if (cmSystemTools::FileExists(link) || cmSystemTools::FileIsSymlink(link)) {
+ if (cmSystemTools::PathExists(link)) {
cmSystemTools::RemoveFile(link);
}
std::string linktext = cmSystemTools::GetFilenameName(file);