Browse Source

- separate files in subdirs

- fixed header file problems using different #ifdef to avoid multiple includes
- added src/test/test_bag.cpp
master
parent
commit
5860cd89d8
20 changed files with 140 additions and 111 deletions
  1. +12
    -7
      src/CMakeLists.txt
  2. +9
    -9
      src/include/bag.hpp
  3. +0
    -0
      src/include/bagmetadata.hpp
  4. +0
    -0
      src/include/fetchfile.hpp
  5. +0
    -0
      src/include/manifest.hpp
  6. +0
    -0
      src/include/othertags.hpp
  7. +21
    -0
      src/include/payload.hpp
  8. +0
    -0
      src/include/tagmanifest.hpp
  9. +18
    -0
      src/lib/load_bag.cpp
  10. +0
    -0
      src/lib/make_bag.cpp
  11. +0
    -0
      src/lib/modify_bag.cpp
  12. +51
    -0
      src/lib/payload.cpp
  13. +0
    -0
      src/lib/store_bag.cpp
  14. +0
    -0
      src/lib/validate_bag.cpp
  15. +0
    -6
      src/load_bag.cpp
  16. +0
    -52
      src/payload.cpp
  17. +0
    -22
      src/payload.hpp
  18. +11
    -0
      src/test/test_bag.cpp
  19. +18
    -0
      src/test/test_payload.cpp
  20. +0
    -15
      src/test_payload.cpp

+ 12
- 7
src/CMakeLists.txt View File

@ -1,7 +1,8 @@
cmake_minimum_required (VERSION 2.6)
project (libcbag)
#include_directories("${PROJECT_SOURCE_DIR}/headers")
#include_directories("${PROJECT_SOURCE_DIR}/validate_icc")
include_directories("${PROJECT_SOURCE_DIR}/include")
include_directories("${PROJECT_SOURCE_DIR}/lib/")
include_directories("${PROJECT_SOURCE_DIR}/")
include (CheckSymbolExists)
include (CheckFunctionExists)
@ -12,13 +13,17 @@ message(status "** Boost Libraries: ${Boost_LIBRARIES}")
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
file( GLOB libcbag_SOURCES
"${PROJECT_SOURCE_DIR}/*.cpp"
file( GLOB libcbag_SOURCES_LIB
"${PROJECT_SOURCE_DIR}/lib/*.cpp"
)
add_library(libcbag ${libcbag_SOURCES} )
add_library(libcbag ${libcbag_SOURCES_LIB} )
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})
add_executable(test_payload ${PROJECT_SOURCE_DIR}/test/test_payload.cpp ${libcbag_SOURCES_lib})
TARGET_LINK_LIBRARIES(test_payload ${Boost_LIBRARIES} libcbag)
add_executable(test_bag ${PROJECT_SOURCE_DIR}/test/test_bag.cpp ${libcbag_SOURCES_lib})
TARGET_LINK_LIBRARIES(test_bag ${Boost_LIBRARIES} libcbag)

src/bag.hpp → src/include/bag.hpp View File


src/bagmetadata.hpp → src/include/bagmetadata.hpp View File


src/fetchfile.hpp → src/include/fetchfile.hpp View File


src/manifest.hpp → src/include/manifest.hpp View File


src/othertags.hpp → src/include/othertags.hpp View File


+ 21
- 0
src/include/payload.hpp View File

@ -0,0 +1,21 @@
#ifndef LIBCBAG_PAYLOAD
#define LIBCBAG_PAYLOAD
#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

src/tagmanifest.hpp → src/include/tagmanifest.hpp View File


+ 18
- 0
src/lib/load_bag.cpp View File

@ -0,0 +1,18 @@
#include "bag.hpp"
#include "payload.hpp"
#include <iostream>
#include <string>
Bag::Bag( string dfname ) {
cout << "load constructor (" << dfname << ")" << endl;
string payloaddir = dfname + "src/";
Bag::payload_p = new Payload( payloaddir ) ;
list<string> files = Bag::payload_p->get_all_relative_paths();
list<string>::iterator i;
for (i=files.begin(); i!=files.end(); i++) {
cout << "file/dir (rel):" << (*i) << endl;
//cout << "file/dir (abs):" << (*i) << endl;
}
}
// vim: set tabstop=4

src/make_bag.cpp → src/lib/make_bag.cpp View File


src/modify_bag.cpp → src/lib/modify_bag.cpp View File


+ 51
- 0
src/lib/payload.cpp View File

@ -0,0 +1,51 @@
#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::recursive_directory_iterator iter(directory), end;
for (; iter != end; ++iter) {
fs::path subdir = iter->path();
paths.push_back( subdir );
}
}
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<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).string() );
}
return strpaths;
}
// vim: set tabstop=4

src/store_bag.cpp → src/lib/store_bag.cpp View File


src/validate_bag.cpp → src/lib/validate_bag.cpp View File


+ 0
- 6
src/load_bag.cpp View File

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

+ 0
- 52
src/payload.cpp View File

@ -1,52 +0,0 @@
#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;
}

+ 0
- 22
src/payload.hpp View File

@ -1,22 +0,0 @@
#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

+ 11
- 0
src/test/test_bag.cpp View File

@ -0,0 +1,11 @@
#include "bag.hpp"
using namespace std;
#include <iostream>
int main() {
Bag bag( "../" );
return 0;
}
// vim: set tabstop=4

+ 18
- 0
src/test/test_payload.cpp View File

@ -0,0 +1,18 @@
#include "payload.hpp"
using namespace std;
#include <iostream>
int main() {
Payload p( "./CMakeFiles" );
//list<string> files = p.get_all_absolute_paths();
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;
//cout << "file/dir (abs):" << (*i) << endl;
}
return 0;
}
// vim: set tabstop=4

+ 0
- 15
src/test_payload.cpp View File

@ -1,15 +0,0 @@
#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;
}

Loading…
Cancel
Save