| 3848 | } |
| 3849 | |
| 3850 | bool HandleArchiveExtractCommand(std::vector<std::string> const& args, |
| 3851 | cmExecutionStatus& status) |
| 3852 | { |
| 3853 | struct Arguments : public ArgumentParser::ParseResult |
| 3854 | { |
| 3855 | std::string Input; |
| 3856 | bool Verbose = false; |
| 3857 | bool ListOnly = false; |
| 3858 | std::string Destination; |
| 3859 | ArgumentParser::MaybeEmpty<std::vector<std::string>> Patterns; |
| 3860 | bool Touch = false; |
| 3861 | }; |
| 3862 | |
| 3863 | static auto const parser = cmArgumentParser<Arguments>{} |
| 3864 | .Bind("INPUT"_s, &Arguments::Input) |
| 3865 | .Bind("VERBOSE"_s, &Arguments::Verbose) |
| 3866 | .Bind("LIST_ONLY"_s, &Arguments::ListOnly) |
| 3867 | .Bind("DESTINATION"_s, &Arguments::Destination) |
| 3868 | .Bind("PATTERNS"_s, &Arguments::Patterns) |
| 3869 | .Bind("TOUCH"_s, &Arguments::Touch); |
| 3870 | |
| 3871 | std::vector<std::string> unrecognizedArguments; |
| 3872 | auto parsedArgs = |
| 3873 | parser.Parse(cmMakeRange(args).advance(1), &unrecognizedArguments); |
| 3874 | auto argIt = unrecognizedArguments.begin(); |
| 3875 | if (argIt != unrecognizedArguments.end()) { |
| 3876 | status.SetError(cmStrCat("Unrecognized argument: \"", *argIt, '"')); |
| 3877 | cmSystemTools::SetFatalErrorOccurred(); |
| 3878 | return false; |
| 3879 | } |
| 3880 | |
| 3881 | if (parsedArgs.MaybeReportError(status.GetMakefile())) { |
| 3882 | cmSystemTools::SetFatalErrorOccurred(); |
| 3883 | return true; |
| 3884 | } |
| 3885 | |
| 3886 | std::string inFile = parsedArgs.Input; |
| 3887 | |
| 3888 | if (parsedArgs.ListOnly) { |
| 3889 | if (!cmSystemTools::ListTar(inFile, parsedArgs.Patterns, |
| 3890 | parsedArgs.Verbose)) { |
| 3891 | status.SetError(cmStrCat("failed to list: ", inFile)); |
| 3892 | cmSystemTools::SetFatalErrorOccurred(); |
| 3893 | return false; |
| 3894 | } |
| 3895 | } else { |
| 3896 | std::string destDir = status.GetMakefile().GetCurrentBinaryDirectory(); |
| 3897 | if (!parsedArgs.Destination.empty()) { |
| 3898 | if (cmSystemTools::FileIsFullPath(parsedArgs.Destination)) { |
| 3899 | destDir = parsedArgs.Destination; |
| 3900 | } else { |
| 3901 | destDir = cmStrCat(destDir, '/', parsedArgs.Destination); |
| 3902 | } |
| 3903 | |
| 3904 | if (!cmSystemTools::MakeDirectory(destDir)) { |
| 3905 | status.SetError(cmStrCat("failed to create directory: ", destDir)); |
| 3906 | cmSystemTools::SetFatalErrorOccurred(); |
| 3907 | return false; |
nothing calls this directly
no test coverage detected
searching dependent graphs…