66 lines
1.8 KiB
C++
66 lines
1.8 KiB
C++
#include <filesystem>
|
|
#include <fstream>
|
|
#include <string>
|
|
|
|
#include "tree.hpp"
|
|
#include "vxheaven_parse.hpp"
|
|
|
|
int main() {
|
|
std::ifstream ifs("./testdata/samples.sort");
|
|
vxorg::VxHeavenTree tree;
|
|
|
|
vxorg::parse_into_tree(tree, ifs);
|
|
|
|
std::filesystem::path root = std::filesystem::current_path() / "testdata";
|
|
std::filesystem::path unorg = root / "unorg";
|
|
std::filesystem::path org = root / "org";
|
|
|
|
if(!std::filesystem::exists(org))
|
|
std::filesystem::create_directories(org);
|
|
|
|
// walk the resulting tree
|
|
tree.walk([&](auto* node) {
|
|
auto tabulation_level = node->parent_count();
|
|
auto& data = node->data();
|
|
|
|
#if 0
|
|
if(tabulation_level != 0) {
|
|
for(auto i = 0; i < tabulation_level; ++i) {
|
|
std::printf("\t");
|
|
}
|
|
}
|
|
|
|
if(node->is_root()) {
|
|
std::printf("(root)\n");
|
|
} else {
|
|
if(data.is_sample) {
|
|
std::string sample_name = vxorg::get_sample_name(node);
|
|
std::printf("%s (sample %s)\n", data.name.c_str(), sample_name.c_str());
|
|
} else {
|
|
std::printf("%s\n", data.name.c_str());
|
|
}
|
|
}
|
|
#endif
|
|
|
|
#if 1
|
|
|
|
if(!node->is_root()) {
|
|
if(data.is_sample) {
|
|
std::string sample_name = vxorg::get_sample_name(node);
|
|
|
|
// paths
|
|
auto path = org / vxorg::get_sample_path(node);
|
|
auto source_path = unorg / vxorg::get_sample_name(node);
|
|
|
|
if(!std::filesystem::exists(source_path)) {
|
|
std::printf("WARNING: sample %s/%s in tree (source disk file %s) does not exist\n", path.string().c_str(), sample_name.c_str(), source_path.string().c_str());
|
|
}
|
|
|
|
|
|
//std::printf("sample %s/%s in tree (source disk file %s)\n", path.string().c_str(), sample_name.c_str(), source_path.string().c_str());
|
|
}
|
|
}
|
|
#endif
|
|
});
|
|
return 0;
|
|
} |