10 #include <Wt/WDateTime.h>
11 #include <Wt/WIconPair.h>
12 #include <Wt/WLocalDateTime.h>
13 #include <Wt/WStringUtil.h>
16 #include <web/FileUtils.h>
18 #include <Wt/cpp17/filesystem.hpp>
28 if (Wt::cpp17::filesystem::exists(path)) {
29 if (!Wt::cpp17::filesystem::is_directory(path)) {
30 int fsize = (int)Wt::cpp17::filesystem::file_size(path);
36 std::time_t t = std::chrono::system_clock::to_time_t(Wt::FileUtils::lastWriteTime(path.string()));
47 if (Wt::cpp17::filesystem::exists(path)
48 && Wt::cpp17::filesystem::is_directory(path))
49 return std::make_unique<WIconPair>(
"icons/yellow-folder-closed.png",
50 "icons/yellow-folder-open.png",
false);
52 return std::make_unique<WIconPair>(
"icons/document.png",
53 "icons/yellow-folder-open.png",
false);
58 if (Wt::cpp17::filesystem::is_directory(
path_)) {
59 std::set<Wt::cpp17::filesystem::path> paths;
60 Wt::cpp17::filesystem::directory_iterator end_itr;
62 for (Wt::cpp17::filesystem::directory_iterator i(
path_); i != end_itr; ++i)
65 }
catch (Wt::cpp17::filesystem::filesystem_error& e) {
66 std::cerr << e.what() << std::endl;
69 for (std::set<Wt::cpp17::filesystem::path>::iterator i = paths.begin();
70 i != paths.end(); ++i)
73 }
catch (Wt::cpp17::filesystem::filesystem_error& e) {
74 std::cerr << e.what() << std::endl;
82 return Wt::cpp17::filesystem::is_directory(
path_);
84 return WTreeTableNode::expandable();
static std::string filename(const fs::path &p)
static std::unique_ptr< WIconPair > createIcon(const cpp17::filesystem::path &path)
Create the iconpair for representing the path.
virtual bool expandable() override
Reimplements WTreeNode::expandable.
cpp17::filesystem::path path_
The path.
virtual void populate() override
Reimplements WTreeNode::populate to read files within a directory.
FileTreeTableNode(const cpp17::filesystem::path &path)
Construct a new node for the given file.
static WDateTime fromTime_t(std::time_t seconds)
bool setTextFormat(TextFormat format)
virtual void setSelectable(bool selectable) override
WTreeNode * addChildNode(std::unique_ptr< WTreeNode > node)
WWidget * columnWidget(int column)
void setColumnWidget(int column, std::unique_ptr< WWidget > item)
WString asString(const cpp17::any &v, const WString &formatString=WString())