|
|
@ -6,10 +6,10 @@ |
|
|
|
#include <string>
|
|
|
|
|
|
|
|
Bag::Bag( string dfname ) { |
|
|
|
cout << "load constructor (" << dfname << ")" << endl; |
|
|
|
// cout << "load constructor (" << dfname << ")" << endl;
|
|
|
|
// read in file bagit.txt
|
|
|
|
string bagit_txt_path = dfname + "bagit.txt"; |
|
|
|
log << "parse " << bagit_txt_path << endl; |
|
|
|
//log << "parse " << bagit_txt_path << endl;
|
|
|
|
ifstream bagit_txt_file; |
|
|
|
bagit_txt_file.open( bagit_txt_path ); |
|
|
|
if (bagit_txt_file.is_open()) { |
|
|
@ -26,10 +26,10 @@ Bag::Bag( string dfname ) { |
|
|
|
getline(version_ss, major ,'.'); |
|
|
|
getline(version_ss, minor, '.'); |
|
|
|
if (0 != vprefix.compare("BagIt-Version:")) { |
|
|
|
log << "wrong vprefix='" << vprefix << "', but 'BagIt-Version:' expected" << endl; |
|
|
|
// log << "wrong vprefix='" << vprefix << "', but 'BagIt-Version:' expected" << endl;
|
|
|
|
} |
|
|
|
cout << "major:'"<<major<<"'"<<endl; |
|
|
|
cout << "minor:'"<<minor<<"'"<<endl; |
|
|
|
//cout << "major:'"<<major<<"'"<<endl;
|
|
|
|
//cout << "minor:'"<<minor<<"'"<<endl;
|
|
|
|
Bag::bagit_version_major = stoi(major); |
|
|
|
Bag::bagit_version_minor = stoi(minor); |
|
|
|
|
|
|
@ -39,15 +39,10 @@ Bag::Bag( string dfname ) { |
|
|
|
getline(utf8_ss, uprefix, ' '); |
|
|
|
getline(utf8_ss, uvalue, ' '); |
|
|
|
if (0 != uprefix.compare("Tag-File-Character-Encoding:")) { |
|
|
|
log << "wrong uprefix='" << uprefix << "', but 'Tag-File-Character-Encoding:' expected" << endl; |
|
|
|
//log << "wrong uprefix='" << uprefix << "', but 'Tag-File-Character-Encoding:' expected" << endl;
|
|
|
|
} |
|
|
|
Bag::tag_file_character_encoding = uvalue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cout << "Bagit Version ("<< version_line << ") major=" << Bag::bagit_version_major << " minor=" << Bag::bagit_version_minor << endl; |
|
|
|
//cout << "Bagit Version ("<< version_line << ") major=" << Bag::bagit_version_major << " minor=" << Bag::bagit_version_minor << endl;
|
|
|
|
} else { |
|
|
|
Bag::log << "file " << bagit_txt_path << " could not be opened" <<endl; |
|
|
|
} |
|
|
@ -64,19 +59,17 @@ Bag::Bag( string dfname ) { |
|
|
|
map<string,string> md = Bag::bagmetadata_p->get_metadata(); |
|
|
|
map<string,string>::iterator m; |
|
|
|
for (m=md.begin(); m!=md.end(); m++) { |
|
|
|
cout << m->first << " = " << m->second <<endl; |
|
|
|
// cout << m->first << " = " << m->second <<endl;
|
|
|
|
} |
|
|
|
|
|
|
|
list<string>::iterator i; |
|
|
|
for (i=files.begin(); i!=files.end(); i++) { |
|
|
|
cout << "file/dir (rel):" << (*i) << endl; |
|
|
|
// cout << "file/dir (rel):" << (*i) << endl;
|
|
|
|
//cout << "file/dir (abs):" << (*i) << endl;
|
|
|
|
} |
|
|
|
Bag::payloadmanifest_p->get_checksum_file_pairs( md5 ); |
|
|
|
Bag::tagmanifest_p->get_checksum_file_pairs( md5 ); |
|
|
|
|
|
|
|
cout << "The bag '"<<dfname<<"' is " << (this->validate() ? "valid" : "invalid") << endl; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// vim: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab
|
|
|
|