diff options
author | scivision <scivision@users.noreply.github.com> | 2023-09-18 03:01:40 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-09-18 20:35:10 (GMT) |
commit | f5ff17fcf29170541805e7fc7f4a74252fe39b10 (patch) | |
tree | eef38695bb40d69488305fd618a85afb424a7e02 /Source/cmcmd.cxx | |
parent | d007eb70468437cb7a1f30d160f3b97263cbc087 (diff) | |
download | CMake-f5ff17fcf29170541805e7fc7f4a74252fe39b10.zip CMake-f5ff17fcf29170541805e7fc7f4a74252fe39b10.tar.gz CMake-f5ff17fcf29170541805e7fc7f4a74252fe39b10.tar.bz2 |
Source: Remove redundant FileIsSymlink checks
Replace `FileExists || FileIsSymlink` with `PathExists`.
The latter does not resolve symlinks, so this is OK for use
with broken symlinks, files, and directories.
Diffstat (limited to 'Source/cmcmd.cxx')
-rw-r--r-- | Source/cmcmd.cxx | 12 |
1 files changed, 5 insertions, 7 deletions
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); |