C++ Library to handle BagIt structures. BagIt is a standard format to create transfer packages for digital preservation purposes. See https://en.wikipedia.org/wiki/BagIt for details http://andreas-romeyke.de
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.5 KiB

#include "payloadmanifest.hpp"
#include <iostream>
#include <fstream>
#include <sstream>
#include <boost/filesystem.hpp>
//#include <filesystem> // c++17
//namespace fs = std::filesystem;
namespace fs = boost::filesystem;
using namespace std;
Payloadmanifest::Payloadmanifest( string basedir ) {
Payloadmanifest::basedir = basedir;
map<checksum_algorithms, string> possible_manifest_files;
for (checksum_algorithms alg : checksum_algorithmsList) {
possible_manifest_files[alg] = "manifest-" + string_of_algorithm( alg ) + ".txt";
}
for (map<checksum_algorithms, string>::iterator it=possible_manifest_files.begin(); it!=possible_manifest_files.end(); ++it) {
checksum_algorithms alg = it->first;
// test if file exists
//string filename = basedir + it->second;
string filename = it->second;
fs::path p{ basedir + filename };
fs::file_status s = fs::status( p );
if (fs::is_regular_file( s)) {
Payloadmanifest::manifest_algorithm_files[alg] = filename;
}
}
}
bool Payloadmanifest::validate() {
bool is_valid = true;
bool tmp = Manifest::validate();
if (false == tmp) { is_valid = false; }
// check if at least one payload file exist
if (0 == this->manifest_algorithm_files.size()) {
this->log << "Bagit payloadmanifest count greater zero expected, but " << to_string(this->manifest_algorithm_files.size()) << " found" << endl;
is_valid = false;
}
return is_valid;
}
// vim: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab