10 #include <boost/filesystem/exception.hpp>
12 #include <boost/version.hpp>
13 #if BOOST_VERSION < 108500
14 #include <boost/filesystem/convenience.hpp>
16 #include <boost/filesystem/directory.hpp>
18 #include <boost/filesystem/operations.hpp>
20 #include <boost/lexical_cast.hpp>
22 #include <Wt/WDateTime.h>
23 #include <Wt/WIconPair.h>
24 #include <Wt/WLocalDateTime.h>
25 #include <Wt/WStringUtil.h>
32 #if BOOST_FILESYSTEM_VERSION < 3
39 label()->setTextFormat(TextFormat::Plain);
41 if (boost::filesystem::exists(path)) {
42 if (!boost::filesystem::is_directory(path)) {
43 int fsize = (int)boost::filesystem::file_size(path);
44 setColumnWidget(1, std::make_unique<WText>(
asString(fsize)));
45 columnWidget(1)->setStyleClass(
"fsize");
49 std::time_t t = boost::filesystem::last_write_time(path);
53 setColumnWidget(2, std::make_unique<WText>(dateTimeStr));
54 columnWidget(2)->setStyleClass(
"date");
60 if (boost::filesystem::exists(path)
61 && boost::filesystem::is_directory(path))
62 return std::make_unique<WIconPair>(
"icons/yellow-folder-closed.png",
63 "icons/yellow-folder-open.png",
false);
65 return std::make_unique<WIconPair>(
"icons/document.png",
66 "icons/yellow-folder-open.png",
false);
71 if (boost::filesystem::is_directory(
path_)) {
72 std::set<boost::filesystem::path> paths;
73 boost::filesystem::directory_iterator end_itr;
75 for (boost::filesystem::directory_iterator i(
path_); i != end_itr; ++i)
78 }
catch (boost::filesystem::filesystem_error& e) {
79 std::cerr << e.what() << std::endl;
82 for (std::set<boost::filesystem::path>::iterator i = paths.begin();
83 i != paths.end(); ++i)
86 }
catch (boost::filesystem::filesystem_error& e) {
87 std::cerr << e.what() << std::endl;
95 return boost::filesystem::is_directory(
path_);
97 return WTreeTableNode::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.
virtual bool expandable() override
Reimplements WTreeNode::expandable.
FileTreeTableNode(const boost::filesystem::path &path)
Construct a new node for the given file.
virtual void populate() override
Reimplements WTreeNode::populate to read files within a directory.
static WDateTime fromTime_t(std::time_t seconds)
WTreeNode * addChildNode(std::unique_ptr< WTreeNode > node)
WString asString(const cpp17::any &v, const WString &formatString=WString())