10 #include <boost/filesystem/operations.hpp> 11 #include <boost/filesystem/exception.hpp> 12 #include <boost/lexical_cast.hpp> 15 #include <Wt/WDateTime> 16 #include <Wt/WIconPair> 17 #include <Wt/WLocalDateTime> 18 #include <Wt/WStringUtil> 24 #if BOOST_FILESYSTEM_VERSION < 3 25 #ifndef WT_NO_STD_WSTRING 35 label()->setTextFormat(PlainText);
37 if (boost::filesystem::exists(path)) {
38 if (!boost::filesystem::is_directory(path)) {
39 int fsize = (int)boost::filesystem::file_size(path);
40 setColumnWidget(1,
new WText(boost::lexical_cast<std::string>(fsize)));
41 columnWidget(1)->setStyleClass(
"fsize");
45 std::time_t t = boost::filesystem::last_write_time(path);
50 setColumnWidget(2,
new WText(dateTimeStr));
51 columnWidget(2)->setStyleClass(
"date");
57 if (boost::filesystem::exists(path)
58 && boost::filesystem::is_directory(path))
59 return new WIconPair(
"icons/yellow-folder-closed.png",
60 "icons/yellow-folder-open.png",
false);
62 return new 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_);
static Wt::WIconPair * createIcon(const boost::filesystem::path &path)
Create the iconpair for representing the path.
virtual void populate()
Reimplements WTreeNode::populate to read files within a directory.
WLocalDateTime toLocalTime(const WLocale &locale=WLocale::currentLocale()) const
virtual bool expandable()
static WDateTime fromTime_t(std::time_t seconds)
virtual bool expandable()
Reimplements WTreeNode::expandable.
FileTreeTableNode(const boost::filesystem::path &path)
Construct a new node for the given file.
A single node in a file tree table.