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.

43 lines
1.3 KiB

#include "bag.hpp"
#include "payload.hpp"
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
Bag::Bag( string dfname ) {
cout << "load constructor (" << dfname << ")" << endl;
// read in file bagit.txt
string bagit_txt_path = dfname + "bagit.txt";
log << "parse " << bagit_txt_path << endl;
ifstream bagit_txt_file;
bagit_txt_file.open( bagit_txt_path );
if (bagit_txt_file.is_open()) {
string version_line;
string utf8_line;
getline(bagit_txt_file, version_line);
getline(bagit_txt_file, utf8_line);
bagit_txt_file.close();
stringstream version_ss ( version_line );
version_ss >> Bag::bagit_version_major;
version_ss >> Bag::bagit_version_minor;
} else {
Bag::log << "file " << bagit_txt_path << " could not be opened" <<endl;
}
// read in payload
string payloaddir = dfname + "data/";
Bag::payload_p = new Payload( payloaddir ) ;
list<string> files = Bag::payload_p->get_all_relative_paths();
// read in payload manifest
Bag::manifest_p = new Manifest(dfname);
list<string>::iterator i;
for (i=files.begin(); i!=files.end(); i++) {
cout << "file/dir (rel):" << (*i) << endl;
//cout << "file/dir (abs):" << (*i) << endl;
}
Bag::manifest_p->get_checksum_file_pairs( md5 );
}
// vim: set tabstop=4