Browse Source

- using mulitmap calling get_checksum_file_pairs()

master
parent
commit
893538752d
2 changed files with 26 additions and 9 deletions
  1. +8
    -2
      src/lib/payloadmanifest.cpp
  2. +18
    -7
      src/lib/tagmanifest.cpp

+ 8
- 2
src/lib/payloadmanifest.cpp View File

@ -27,10 +27,13 @@ Payloadmanifest::Payloadmanifest( string basedir ) {
if (fs::is_regular_file( s)) {
Payloadmanifest::manifest_algorithm_files[it->first] = filename;
// debug
cout << "PAYLOADMANIFEST: alg="<< it->first << " => filename=" << it->second << endl;
//cout << "PAYLOADMANIFEST: alg="<< it->first << " => filename=" << it->second << endl;
// cout << " alg="<< it->first << " => filename=" << Payloadmanifest::manifest_algorithm_files[it->first] << endl;
}
}
//cout << "PAYLOADMANIFEST constructor, calling debug()" << endl;
//this->debug();
//cout << "PAYLOADMANIFEST constructor, finished" << endl;
}
bool Payloadmanifest::validate( list<string> & log ) {
@ -38,11 +41,14 @@ bool Payloadmanifest::validate( list<string> & log ) {
bool tmp = Manifest::validate( log );
if (false == tmp) { is_valid = false; }
// check if at least one payload file exist
cout << "payload_manifest: " << this->manifest_algorithm_files.size() << endl;
//cout << "payload_manifest: " << this->manifest_algorithm_files.size() << endl;
if (0 == this->manifest_algorithm_files.size()) {
log.push_back("Bagit payloadmanifest count greater zero expected, but " + to_string(this->manifest_algorithm_files.size()) + " found");
is_valid = false;
}
//cout << "PAYLOADMANIFEST validate, calling debug()" << endl;
//this->debug();
//cout << "PAYLOADMANIFEST validate, finished" << endl;
return is_valid;
}


+ 18
- 7
src/lib/tagmanifest.cpp View File

@ -19,30 +19,41 @@ Tagmanifest::Tagmanifest( string basedir ) {
possible_manifest_files[sha1] = "tagmanifest-sha1.txt";
for (map<checksum_algorithms, string>::iterator it=possible_manifest_files.begin(); it!=possible_manifest_files.end(); ++it) {
// debug
cout << it->first << " => " << it->second << endl;
// cout << it->first << " => " << it->second << endl;
// test if file exists
string filename = basedir + it->second;
fs::path p{ filename };
fs::file_status s = fs::status( p );
cout << "path "<< p.string() << endl;
cout << "is file: "<< fs::is_regular_file( s) << endl;
//cout << "path "<< p.string() << endl;
//cout << "is file: "<< fs::is_regular_file( s) << endl;
if (fs::is_regular_file( s)) {
Tagmanifest::manifest_algorithm_files[it->first] = filename;
// debug
cout << "TAGMANIFEST: alg="<< it->first << " => filename=" << it->second << endl;
//cout << "TAGMANIFEST: alg="<< it->first << " => filename=" << it->second << endl;
//cout << "TAGMANIFEST2: alg="<< it->first << " => filename=" << filename << endl;
}
}
this->exist_manifest_files = possible_manifest_files.empty();
//cout << "TAGMANIFEST constructor, calling debug()" << endl;
//this->debug();
//cout << "TAGMANIFEST constructor, finished" << endl;
}
map<string,string> Tagmanifest::get_checksum_file_pairs(checksum_algorithms alg) {
map<string,string> checksum_file_pairs = Manifest::get_checksum_file_pairs(alg);
multimap<checksum_string_t,filename_t> Tagmanifest::get_checksum_file_pairs(checksum_algorithms alg) {
//cout << "DEBUG: begin Tagmanifest::get_checksum_file_pairs" << endl;
multimap<checksum_string_t,filename_t> checksum_file_pairs = Manifest::get_checksum_file_pairs(alg);
//cout << "DEBUG: called super->get_checksum_file_pairs" << endl;
for (map<string,string>::iterator it=checksum_file_pairs.begin(); it!=checksum_file_pairs.end(); ++it) {
for (multimap<checksum_string_t,filename_t>::iterator it=checksum_file_pairs.begin(); it!=checksum_file_pairs.end(); ++it) {
// cout << "DEBUG: TAGMANIFEST found 'data/' in the beginning of file '"<<it->second<<"' in tagmanifest file '"<< this->manifest_algorithm_files[ alg] << endl;
if (it->second.find( "data/" ) == 0) {
cout << "found 'data/' in the beginning of file '"<<it->second<<"' in tagmanifest file '"<< this->manifest_algorithm_files[ alg] << endl;
}
}
//cout << "TAGMANIFEST get_checksum_file_pairs, calling debug()" << endl;
//this->debug();
//cout << "TAGMANIFEST get_checksum_file_pairs, finished" << endl;
return checksum_file_pairs;
}


Loading…
Cancel
Save