#include <nana/deploy.hpp>
#include <nana/gui.hpp>
#include <nana/gui/widgets/treebox.hpp>
#include <nana/filesystem/filesystem_ext.hpp>
int main()
{
using namespace nana;
namespace fs = std::filesystem;
namespace fs_ext = nana::filesystem_ext;
using SubDirectories = fs::directory_iterator;
fm.caption("Nana C++ Library - Treebox-nana::experimental::filesystem example.");
auto node = tree.
insert(fs_ext::def_root, fs_ext::def_rootname);
try {
for (const auto& dir : SubDirectories{ fs_ext::def_rootstr })
{
if (! fs::is_directory(dir) ) continue;
tree.insert(node, dir.path().filename().generic_string(), dir.path().filename().generic_string());
break;
}
} catch (...) {}
{
auto Path = tree.make_key_path(arg.
item,
"/") +
"/";
tree.auto_draw(false);
try {
for (const auto& dir : SubDirectories{ Path })
{
if (!fs::is_directory(dir)) continue;
auto child = tree.insert(arg.
item, dir.path().filename().generic_string(),
dir.path().filename().generic_string());
if (child.empty()) continue;
try {
for (const auto& dr : SubDirectories{ dir.path() })
{
if (!fs::is_directory(dr)) continue;
tree.insert(child, dr.path().filename().generic_string(),
dr.path().filename().generic_string());
break;
}
} catch (...) {}
}
} catch (...) {}
tree.auto_draw(true);
});
fm.show();
#ifdef NANA_AUTOMATIC_GUI_TESTING
2, 1, [&node]()
{
node.expand(true);
}
#endif
);
}