diff --git a/src/include/bagmetadata.hpp b/src/include/bagmetadata.hpp index d1a337c..c800aa7 100644 --- a/src/include/bagmetadata.hpp +++ b/src/include/bagmetadata.hpp @@ -45,7 +45,7 @@ class Bagmetadata{ stringstream log; public: - Bagmetadata( string basedir ); + explicit Bagmetadata( string basedir ); string get_SourceOrganization(); string get_OrganizationAddress(); diff --git a/src/include/othertags.hpp b/src/include/othertags.hpp index c6d622a..c3dd57b 100644 --- a/src/include/othertags.hpp +++ b/src/include/othertags.hpp @@ -23,7 +23,7 @@ class Othertags{ stringstream log; public: Othertags( string basedir); - bool store( string basedir); + static bool store( string basedir); bool set_other_tag_files( list &); list get_other_tag_files(); void get_logstream( stringstream & log); diff --git a/src/lib/bag.cpp b/src/lib/bag.cpp index 482721f..f0bd6fb 100644 --- a/src/lib/bag.cpp +++ b/src/lib/bag.cpp @@ -27,6 +27,10 @@ using namespace std; Bag::Bag( string dfname ) { + + if ('/' != dfname.back()) { + dfname += "/"; + } // log << "load constructor (" << dfname << ")" << endl; // read in file bagit.txt string bagit_txt_path = dfname + "bagit.txt"; diff --git a/src/lib/bagmetadata.cpp b/src/lib/bagmetadata.cpp index 9fdec90..b12c679 100644 --- a/src/lib/bagmetadata.cpp +++ b/src/lib/bagmetadata.cpp @@ -131,8 +131,8 @@ oxum_t Bagmetadata::get_PayloadOxum() { string sstreams; getline(oxumstring, soctets, '.'); getline(oxumstring, sstreams, '.'); - oxum.octetcount = stoi( soctets ); - oxum.streamcount = stoi( sstreams ); + oxum.octetcount = stoul( soctets ); + oxum.streamcount = stoul( sstreams ); } return oxum; } @@ -376,7 +376,7 @@ void Bagmetadata::set_BagSize(string BagSize) { void Bagmetadata::set_BagSize( unsigned long long int bytes) { - if (bytes > (const unsigned long long int) (1024ull*1024ull*1024ull*1024ull) ) { + if (bytes > 1024ull * 1024ull * 1024ull * 1024ull) { this->metadata["BagSize"] = to_string (bytes/ (1024ull*1024ull*1024ull*1024ull)) + " TB"; } else if (bytes > (1024ull *1024ull*1024ull) ) { this->metadata["BagSize"] = to_string (bytes/ (1024ull*1024ull*1024ull)) + " GB"; diff --git a/src/lib/fetchfile.cpp b/src/lib/fetchfile.cpp index 61c3084..ea3c672 100644 --- a/src/lib/fetchfile.cpp +++ b/src/lib/fetchfile.cpp @@ -58,7 +58,7 @@ Fetchfile::Fetchfile( string basedir ) { line_ss >> subfile; fetch_t entry; entry.url = url; - entry.size = stoi( length ); + entry.size = stoul( length ); entry.filename = subfile; this->entries.push_back( entry ); } @@ -71,7 +71,6 @@ Fetchfile::Fetchfile( string basedir ) { bool Fetchfile::fetch( fetch_t fetch ) { CURL *curl; - CURLcode result; curl = curl_easy_init(); if (curl != nullptr) { FILE *fp; @@ -81,7 +80,7 @@ bool Fetchfile::fetch( fetch_t fetch ) { // see https://curl.haxx.se/libcurl/c/CURLOPT_WRITEFUNCTION.html#DESCRIPTION curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL); curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); - result = curl_easy_perform(curl); + CURLcode result = curl_easy_perform(curl); curl_easy_cleanup(curl); fclose(fp); } else { diff --git a/src/lib/manifest.cpp b/src/lib/manifest.cpp index d6871c4..72765b2 100644 --- a/src/lib/manifest.cpp +++ b/src/lib/manifest.cpp @@ -89,8 +89,8 @@ bool Manifest::validate() { for (auto & manifest_algorithm_file : this->manifest_algorithm_files) { string manifest_file = manifest_algorithm_file.second; checksum_algorithms alg = manifest_algorithm_file.first; - fs::path p{ manifest_file }; - if (fs::is_regular_file( p )) { + fs::path manifest_path{manifest_file }; + if (fs::is_regular_file(manifest_path )) { at_least_one_manifest=true; } @@ -108,9 +108,9 @@ bool Manifest::validate() { this->log << "Bagit file '" << file << "', checksum '" << expected_checksum << "' is expected by file '" << manifest_file << "', but found: '" << calc_checksum << "'" << endl; is_valid = false; } - fs::path p{ file }; + fs::path file_path{file }; // fs::file_status s = fs::status( p ); - if (! fs::is_regular_file( p )) { + if (! fs::is_regular_file(file_path )) { this->log << "Bagit file '" << file << "' does not exists in '" << this->basedir << "'" << endl; } } diff --git a/test/test_tagmanifest.cpp b/test/test_tagmanifest.cpp index 926eb90..c2fb95d 100644 --- a/test/test_tagmanifest.cpp +++ b/test/test_tagmanifest.cpp @@ -33,14 +33,13 @@ bool check_get_checksum_file_pairs() { {"eaa2c609ff6371712f623f5531945b44", "bagit.txt"}, }; multimap::iterator i; - multimap::iterator j; bool is_valid = true; for (i=expected.begin(); i!=expected.end() ; i++) { cout << "Expected: (" << (i->first) << "," << (i->second) << ")" << endl; - auto j = results.find( i->first ); - if (j != results.end()) { // file found - if (j->first != i->first) { - cout << "Results: (" << (j->first) << "," << (j->second) << ")" << endl; + auto idx_first_match = results.find(i->first ); + if (idx_first_match != results.end()) { // file found + if (idx_first_match->first != i->first) { + cout << "Results: (" << (idx_first_match->first) << "," << (idx_first_match->second) << ")" << endl; is_valid=false; break; } } else { diff --git a/test/testbag.cpp b/test/testbag.cpp index ee330e8..d9f4980 100644 --- a/test/testbag.cpp +++ b/test/testbag.cpp @@ -169,8 +169,6 @@ BOOST_AUTO_TEST_CASE(check_invalid_dirs) { check_invalid_dirs(); } - - BOOST_FIXTURE_TEST_CASE(check_store_ok, TARGETFIXTURE) { BOOST_TEST(check_store("../testbags/bag_minimal_ok/", targetdir)); };