 |
ewmscp
..
|
Go to the documentation of this file.
8 "schema used for escaping file names in checksum file",
"C"));
10 "check sum type in type-less check sum check files");
12 "map for guessing check sum types from their length",
13 {{8,
"adler32"}, {32,
"md5sum"}, {56,
"sha224"}, {64,
"sha265"}, {96,
"sha384"}, {128,
"sha512"}});
21 'c',
"check",
"just do checksum tests like md5sum -c");
38 std::unique_ptr<const genericStat>& aStat,
42 std::ostream& logStream)
override {
44 bool matchesInAllSums =
true;
46 if (!sum->getExpectedResult().empty()) {
47 matchesInAllSums &= sum->checkExpectation();
48 if (!
quiet || sum->checkExpectation() ==
false) {
50 escaper->escape(
source, name);
51 logStream << name << (sum->checkExpectation() ?
": OK\n" :
": FAILED\n");
55 if (! matchesInAllSums) {
62 <<
" did NOT match\n";
64 throw std::runtime_error(
"bad checksums found");
92 std::ifstream srcList(source);
98 if (sumType.empty()) {
101 if (sumType.back() ==
':') {
105 if (sumType.front() ==
'\\') {
106 sumValue = sumType.substr(1);
111 auto item =
lengthMap.find(sumValue.size());
113 throw std::runtime_error(
"can't guess checksum type from checksum length " + sumValue);
115 sumType = item->second;
121 std::getline(srcList, line);
127 escaper->deEscape(line.substr(line.find_first_not_of(
" \t")), src);
133 throw std::runtime_error(
"no such file or directory " + src);
136 if (sourceStat->isDir()) {
137 throw std::runtime_error(src +
" is a directory");
140 request->addExpectedChecksumResult(sumType, sumValue);
146 std::string& destination) {
147 if (!destination.empty()) {
148 sources.push_back(destination);
class for checking if checksums match expectations Extends the copyRequest::base class with new print...
static options::single< bool > ignoreMissing
class specialisation for options of type bool
options::single< std::string > requestProviderName
void processSource(const std::string &source) override
static singleMap mapEntry
std::chrono::system_clock clock_type
type for time measurements
static options::single< bool > exitOnMismatch
void prepareMappings(std::vector< std::string > &sources, std::string &destination) override
checksumTest(const std::string &aSource, std::unique_ptr< const genericStat > &aStat, inputHandler::base *aInputHandler)
static options::single< std::string > * newEscaperOption(const std::string &name, const std::string &description, const std::string &defaultValue="Url")
static options::withAction< options::single< bool > > doCheck
void printResults(std::ostream &, std::ostream &logStream) override
static void printFinalLine(std::ostream &stream)
static const escapism * newEscaper(const std::string &name)
virtual std::unique_ptr< const genericStat > getStat(const std::string &path, bool followLink=true)=0
static void prepareStatPrint()
setup statPrinter to print the final line for compatibiity mith eg. md5sum
options::single< bool > printStatAnyway
std::pair< std::string, std::string > singleMap
inputHandler::base * InputHandler
static factoryTemplate< checksumTestRequestProvider > factory
static std::multiset< copyRequest::base *, copyRequest::base::pointerCompare > requestSet
static std::function< void(std::ostream &)> statPrinter
static options::single< bool > quiet('q', "quiet", "be quiet, no prefix to output lines")
static options::single< std::string > defaultSum
static options::single< std::string > & escaperOption
std::list< checksum::base * > checkSums
#define defineStatic(var,...)
defines a static variable and instatitates the constructor with the variable number of arguments.
static unsigned int numberOfMismatches
static options::map< std::string, std::map< int, std::string > > lengthMap