10 #include <boost/filesystem/operations.hpp> 11 #include <boost/filesystem/exception.hpp> 12 #include <boost/lexical_cast.hpp> 16 #include <Wt/WIconPair.h> 17 #include <Wt/WStringUtil.h> 22 #if BOOST_FILESYSTEM_VERSION < 3 29 label()->setTextFormat(TextFormat::Plain);
31 if (boost::filesystem::exists(path)) {
32 if (!boost::filesystem::is_directory(path)) {
33 int fsize = (int)boost::filesystem::file_size(path);
34 setColumnWidget(1, cpp14::make_unique<WText>(
asString(fsize)));
35 columnWidget(1)->setStyleClass(
"fsize");
39 std::time_t t = boost::filesystem::last_write_time(path);
44 localtime_r(&t, &ttm);
48 strftime(c, 100,
"%b %d %Y", &ttm);
50 setColumnWidget(2, cpp14::make_unique<WText>(c));
51 columnWidget(2)->setStyleClass(
"date");
57 if (boost::filesystem::exists(path)
58 && boost::filesystem::is_directory(path))
59 return cpp14::make_unique<WIconPair>(
"icons/yellow-folder-closed.png",
60 "icons/yellow-folder-open.png",
false);
62 return cpp14::make_unique<WIconPair>(
"icons/document.png",
63 "icons/yellow-folder-open.png",
false);
68 if (boost::filesystem::is_directory(
path_)) {
69 std::set<boost::filesystem::path> paths;
70 boost::filesystem::directory_iterator end_itr;
72 for (boost::filesystem::directory_iterator i(
path_); i != end_itr; ++i)
75 }
catch (boost::filesystem::filesystem_error& e) {
76 std::cerr << e.what() << std::endl;
79 for (std::set<boost::filesystem::path>::iterator i = paths.begin();
80 i != paths.end(); ++i)
83 }
catch (boost::filesystem::filesystem_error& e) {
84 std::cerr << e.what() << std::endl;
92 return boost::filesystem::is_directory(
path_);
94 return WTreeTableNode::expandable();
WTreeNode * addChildNode(std::unique_ptr< WTreeNode > node)
virtual bool expandable() override
Reimplements WTreeNode::expandable.
boost::filesystem::path path_
The path.
static std::unique_ptr< WIconPair > createIcon(const boost::filesystem::path &path)
Create the iconpair for representing the path.
WString asString(const cpp17::any &v, const WString &formatString=WString())
virtual void populate() override
Reimplements WTreeNode::populate to read files within a directory.
FileTreeTableNode(const boost::filesystem::path &path)
Construct a new node for the given file.