Browse Source

- init

master
commit
61e12fd9e8
  1. 24
      src/CMakeLists.txt
  2. 30
      src/bag.hpp
  3. 11
      src/bagmetadata.hpp
  4. 11
      src/fetchfile.hpp
  5. 6
      src/load_bag.cpp
  6. 0
      src/make_bag.cpp
  7. 11
      src/manifest.hpp
  8. 0
      src/modify_bag.cpp
  9. 11
      src/othertags.hpp
  10. 52
      src/payload.cpp
  11. 22
      src/payload.hpp
  12. 0
      src/store_bag.cpp
  13. 11
      src/tagmanifest.hpp
  14. 15
      src/test_payload.cpp
  15. 0
      src/validate_bag.cpp

24
src/CMakeLists.txt

@ -0,0 +1,24 @@
cmake_minimum_required (VERSION 2.6)
project (libcbag)
#include_directories("${PROJECT_SOURCE_DIR}/headers")
#include_directories("${PROJECT_SOURCE_DIR}/validate_icc")
include (CheckSymbolExists)
include (CheckFunctionExists)
find_package(Boost 1.47 COMPONENTS filesystem unit_test_framework REQUIRED)
message(status "** Boost Include: ${Boost_INCLUDE_DIR}")
message(status "** Boost Libraries: ${Boost_LIBRARY_DIRS}")
message(status "** Boost Libraries: ${Boost_LIBRARIES}")
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
file( GLOB libcbag_SOURCES
"${PROJECT_SOURCE_DIR}/*.cpp"
)
add_library(libcbag ${libcbag_SOURCES} )
target_include_directories(libcbag PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
add_executable(test_payload test_payload.cpp ${libcbag_SOURCES})
TARGET_LINK_LIBRARIES(test_payload ${Boost_LIBRARIES})

30
src/bag.hpp

@ -0,0 +1,30 @@
#ifndef LIBCBAG
#define LIBCBAG
#include <string>
#include "payload.hpp"
#include "manifest.hpp"
#include "tagmanifest.hpp"
#include "bagmetadata.hpp"
#include "fetchfile.hpp"
#include "othertags.hpp"
using namespace std;
class bag {
private:
string base_dir; // from where the bag was loaded, optional
class payload;
class manifest; // TODO: list of manifests
class tagmanifest; // TODO: list of tag manifests, optional
class bagmetadata;
class fetchfile;
class othertags; //TODO: optional
public:
bag();
bag( string dfname);
bool store( string dfname);
bool validate();
};
#endif
// vim: set tabstop=4

11
src/bagmetadata.hpp

@ -0,0 +1,11 @@
#ifndef LIBCBAG
#define LIBCBAG
#include <string>
using namespace std;
class bagmetadata{
public:
bagmetadata();
};
#endif
// vim: set tabstop=4

11
src/fetchfile.hpp

@ -0,0 +1,11 @@
#ifndef LIBCBAG
#define LIBCBAG
#include <string>
using namespace std;
class fetchfile{
public:
fetchfile();
};
#endif
// vim: set tabstop=4

6
src/load_bag.cpp

@ -0,0 +1,6 @@
#include "bag.hpp"
#include <iostream>
bag::bag( string dfname ) {
cout << "load constructor (" << dfname << endl;
}

0
src/make_bag.cpp

11
src/manifest.hpp

@ -0,0 +1,11 @@
#ifndef LIBCBAG
#define LIBCBAG
#include <string>
using namespace std;
class manifest{
public:
manifest();
};
#endif
// vim: set tabstop=4

0
src/modify_bag.cpp

11
src/othertags.hpp

@ -0,0 +1,11 @@
#ifndef LIBCBAG
#define LIBCBAG
#include <string>
using namespace std;
class othertags{
public:
othertags();
};
#endif
// vim: set tabstop=4

52
src/payload.cpp

@ -0,0 +1,52 @@
#include "payload.hpp"
#include <boost/filesystem.hpp>
#include <iostream>
#include <string>
#include <list>
//#include <filesystem> // c++17
//namespace fs = std::filesystem;
namespace fs = boost::filesystem;
using namespace std;
payload::payload( string basedir ) {
fs::path p{ basedir };
fs::file_status s = fs::status( p );
cout << "basedir "<< p.string() << endl;
cout << "is dir: "<< fs::is_directory( s) << endl;
cout << "exists: "<< fs::exists(s) << endl;
this->basedir = basedir;
};
void payload::scan_dir_recursively( fs::path directory, list<fs::path> &paths) {
fs::directory_iterator iter(directory), end;
for (; iter != end; ++iter) {
fs::path subdir = iter->path();
paths.push_back( subdir );
// dive deeper
payload::scan_dir_recursively( subdir, paths );
}
}
list<string> payload::get_all_relative_paths() {
list<fs::path> paths;
list<string> strpaths;
fs::path directory(this->basedir);
payload::scan_dir_recursively( directory, paths);
list<fs::path>::iterator i;
for (i=paths.begin(); i!= paths.end(); i++) {
strpaths.push_back( (*i).relative_path().string() );
}
return strpaths;
}
list<string> payload::get_all_absolute_paths() {
list<string> paths;
fs::path directory(this->basedir);
fs::directory_iterator iter(directory), end;
for (; iter != end; ++iter) {
paths.push_back( iter->path().string() );
}
return paths;
}

22
src/payload.hpp

@ -0,0 +1,22 @@
#ifndef LIBCBAG
#define LIBCBAG
#include <string>
#include <list>
#include <boost/filesystem.hpp>
#include <list>
//namespace fs = std::filesystem;
namespace fs = boost::filesystem;
using namespace std;
class payload{
private:
string basedir;
void scan_dir_recursively( fs::path directory, list<fs::path> &paths );
public:
payload( string basedir );
list<string> get_all_relative_paths();
list<string> get_all_absolute_paths();
};
#endif
// vim: set tabstop=4

0
src/store_bag.cpp

11
src/tagmanifest.hpp

@ -0,0 +1,11 @@
#ifndef LIBCBAG
#define LIBCBAG
#include <string>
using namespace std;
class tagmanifest{
public:
tagmanifest();
};
#endif
// vim: set tabstop=4

15
src/test_payload.cpp

@ -0,0 +1,15 @@
#include "payload.hpp"
using namespace std;
#include <iostream>
int main() {
payload p( "/tmp/" );
list<string> files = p.get_all_relative_paths();
list<string>::iterator i;
for (i=files.begin(); i!=files.end(); i++) {
cout << "file/dir (rel):" << (*i) << endl;
}
return 0;
}

0
src/validate_bag.cpp

Loading…
Cancel
Save