diff options
Diffstat (limited to 'Source/cmFileCommand.cxx')
| -rw-r--r-- | Source/cmFileCommand.cxx | 57 |
1 files changed, 40 insertions, 17 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index fe38db5..dfce033 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -845,8 +845,10 @@ bool HandleMakeDirectoryCommand(std::vector<std::string> const& args, cmSystemTools::SetFatalErrorOccurred(); return false; } - if (!cmSystemTools::MakeDirectory(*cdir)) { - std::string error = "problem creating directory: " + *cdir; + cmsys::Status mkdirStatus = cmSystemTools::MakeDirectory(*cdir); + if (!mkdirStatus) { + std::string error = cmStrCat("failed to create directory:\n ", *cdir, + "\nbecause: ", mkdirStatus.GetString()); status.SetError(error); return false; } @@ -1408,12 +1410,14 @@ bool HandleCopyFile(std::vector<std::string> const& args, struct Arguments { + bool InputMayBeRecent = false; bool OnlyIfDifferent = false; std::string Result; }; static auto const parser = cmArgumentParser<Arguments>{} + .Bind("INPUT_MAY_BE_RECENT"_s, &Arguments::InputMayBeRecent) .Bind("ONLY_IF_DIFFERENT"_s, &Arguments::OnlyIfDifferent) .Bind("RESULT"_s, &Arguments::Result); @@ -1456,9 +1460,13 @@ bool HandleCopyFile(std::vector<std::string> const& args, } else { when = cmSystemTools::CopyWhen::Always; } + cmSystemTools::CopyInputRecent const inputRecent = arguments.InputMayBeRecent + ? cmSystemTools::CopyInputRecent::Yes + : cmSystemTools::CopyInputRecent::No; std::string err; - if (cmSystemTools::CopySingleFile(oldname, newname, when, &err) == + if (cmSystemTools::CopySingleFile(oldname, newname, when, inputRecent, + &err) == cmSystemTools::CopyResult::Success) { if (!arguments.Result.empty()) { status.GetMakefile().AddDefinition(arguments.Result, "0"); @@ -2107,6 +2115,14 @@ bool HandleDownloadCommand(std::vector<std::string> const& args, // Verify MD5 sum if requested: // if (hash) { + if (res != CURLE_OK) { + status.SetError(cmStrCat( + "DOWNLOAD cannot compute hash on failed download\n" + " status: [", + static_cast<int>(res), ";\"", ::curl_easy_strerror(res), "\"]")); + return false; + } + std::string actualHash = hash->HashFile(file); if (actualHash.empty()) { status.SetError("DOWNLOAD cannot compute hash on downloaded file"); @@ -2130,11 +2146,7 @@ bool HandleDownloadCommand(std::vector<std::string> const& args, expectedHash, "]\n" " actual hash: [", - actualHash, - "]\n" - " status: [", - static_cast<int>(res), ";\"", - ::curl_easy_strerror(res), "\"]\n")); + actualHash, "]\n")); return false; } } @@ -2458,11 +2470,13 @@ void AddEvaluationFile(const std::string& inputName, { cmListFileBacktrace lfbt = status.GetMakefile().GetBacktrace(); - cmGeneratorExpression outputGe(lfbt); + cmGeneratorExpression outputGe(*status.GetMakefile().GetCMakeInstance(), + lfbt); std::unique_ptr<cmCompiledGeneratorExpression> outputCge = outputGe.Parse(outputExpr); - cmGeneratorExpression conditionGe(lfbt); + cmGeneratorExpression conditionGe(*status.GetMakefile().GetCMakeInstance(), + lfbt); std::unique_ptr<cmCompiledGeneratorExpression> conditionCge = conditionGe.Parse(condition); @@ -3398,20 +3412,29 @@ bool HandleArchiveCreateCommand(std::vector<std::string> const& args, } int compressionLevel = 0; + int minCompressionLevel = 0; + int maxCompressionLevel = 9; + if (compress == cmSystemTools::TarCompressZstd) { + maxCompressionLevel = 19; + } + if (!parsedArgs.CompressionLevel.empty()) { if (parsedArgs.CompressionLevel.size() != 1 && !std::isdigit(parsedArgs.CompressionLevel[0])) { - status.SetError(cmStrCat("compression level ", - parsedArgs.CompressionLevel, - " should be in range 0 to 9")); + status.SetError( + cmStrCat("compression level ", parsedArgs.CompressionLevel, " for ", + parsedArgs.Compression, " should be in range ", + minCompressionLevel, " to ", maxCompressionLevel)); cmSystemTools::SetFatalErrorOccurred(); return false; } compressionLevel = std::stoi(parsedArgs.CompressionLevel); - if (compressionLevel < 0 || compressionLevel > 9) { - status.SetError(cmStrCat("compression level ", - parsedArgs.CompressionLevel, - " should be in range 0 to 9")); + if (compressionLevel < minCompressionLevel || + compressionLevel > maxCompressionLevel) { + status.SetError( + cmStrCat("compression level ", parsedArgs.CompressionLevel, " for ", + parsedArgs.Compression, " should be in range ", + minCompressionLevel, " to ", maxCompressionLevel)); cmSystemTools::SetFatalErrorOccurred(); return false; } |
