From 159831cfaba837e0647997880cfe60c6104a56c0 Mon Sep 17 00:00:00 2001 From: "art1@andreas-romeyke.de" Date: Tue, 29 May 2018 17:41:55 +0200 Subject: [PATCH] - added Manifest - parse version --- src/lib/load_bag.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/lib/load_bag.cpp b/src/lib/load_bag.cpp index 84e42dc..a66d35b 100644 --- a/src/lib/load_bag.cpp +++ b/src/lib/load_bag.cpp @@ -1,18 +1,43 @@ #include "bag.hpp" #include "payload.hpp" #include +#include +#include #include 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" < files = Bag::payload_p->get_all_relative_paths(); + // read in payload manifest + Bag::manifest_p = new Manifest(dfname); + list::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