Browse Source

- added create_new()

master
Andreas Romeyke 2 years ago
parent
commit
b0e28c901f
4 changed files with 27 additions and 13 deletions
  1. +7
    -2
      src/CMakeLists.txt
  2. +3
    -3
      src/examples/validate_a_bag.cpp
  3. +5
    -4
      src/include/bag.hpp
  4. +12
    -4
      src/lib/bag.cpp

+ 7
- 2
src/CMakeLists.txt View File

@@ -50,6 +50,11 @@ target_include_directories(cbag PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
add_executable(test_payload examples/test_payload.cpp ${libcbag_SOURCES_lib})
TARGET_LINK_LIBRARIES(test_payload ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${CURL_LIBRARIES} cbag)
#add_executable(test_bag ${PROJECT_SOURCE_DIR}/examples/test_bag.cpp ${libcbag_SOURCES_lib})
add_executable(test_bag examples/test_bag.cpp ${libcbag_SOURCES_lib})

add_executable(validate_a_bag examples/validate_a_bag.cpp ${libcbag_SOURCES_lib})
#TARGET_LINK_LIBRARIES(test_bag ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${POCO_NET_LIBRARIES} cbag)
TARGET_LINK_LIBRARIES(validate_a_bag ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${CURL_LIBRARIES} cbag)

add_executable(create_a_bag examples/create_a_bag.cpp ${libcbag_SOURCES_lib})
#TARGET_LINK_LIBRARIES(test_bag ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${POCO_NET_LIBRARIES} cbag)
TARGET_LINK_LIBRARIES(test_bag ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${CURL_LIBRARIES} cbag)
TARGET_LINK_LIBRARIES(create_a_bag ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${CURL_LIBRARIES} cbag)

+ 3
- 3
src/examples/validate_a_bag.cpp View File

@@ -1,15 +1,15 @@
// Copyright (C) 2018 Andreas Romeyke (art1@andreas-romeyke.de), 2018.
//
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "bag.hpp"


+ 5
- 4
src/include/bag.hpp View File

@@ -1,15 +1,15 @@
// Copyright (C) 2018 Andreas Romeyke (art1@andreas-romeyke.de), 2018.
//
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef LIBCBAG
@@ -44,9 +44,10 @@ class Bag {
public:
Bag();
Bag(string dfname);
list<string> get_all_bag_files();
list<string> get_all_bag_files();
bool store( string basedir);
bool validate();
void create_new(Payload * payload_p);
void get_logstream( stringstream & log);
void reset_logstream();
};


+ 12
- 4
src/lib/bag.cpp View File

@@ -1,15 +1,15 @@
// Copyright (C) 2018 Andreas Romeyke (art1@andreas-romeyke.de), 2018.
//
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "bag.hpp"
@@ -108,7 +108,7 @@ bool Bag::store( string basedir ) {
fs::file_status s = fs::status( p );
if (fs::is_directory( s)) {
log << "directory '" << basedir << "' already exists" << endl;
return false;
// return false;
}
fs::create_directory(p);

@@ -299,6 +299,14 @@ bool Bag::validate() {
return is_valid;
}

void Bag::create_new( Payload * payload_p ) {
this->payload_p = payload_p;
/* add metadata and stuff */
this->bagit_version_major = 0;
this->bagit_version_minor = 97;
this->tag_file_character_encoding = "UTF-8";
}

void Bag::get_logstream( stringstream & log ) {
log << this->log.rdbuf();
}


Loading…
Cancel
Save