Browse Source

- added Manifest

- parse version
master
parent
commit
159831cfab
1 changed files with 26 additions and 1 deletions
  1. +26
    -1
      src/lib/load_bag.cpp

+ 26
- 1
src/lib/load_bag.cpp View File

@ -1,18 +1,43 @@
#include "bag.hpp"
#include "payload.hpp"
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
Bag::Bag( string dfname ) {
cout << "load constructor (" << dfname << ")" << endl;
string payloaddir = dfname + "src/";
// 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

Loading…
Cancel
Save