Testing more of the filesystem API
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
/// @file FileDialog.hpp
|
||||
/// @desc A dialog window that shows a selection of files on disk, and a form for naming, used for file loading and saving.
|
||||
|
||||
/// @edit 2024-5-29
|
||||
|
||||
#pragma once
|
||||
@@ -17,7 +18,6 @@
|
||||
|
||||
namespace JUI
|
||||
{
|
||||
|
||||
class FileListing : public JUI::Widget { };
|
||||
|
||||
class FileDialogWindow : public JUI::Window
|
||||
@@ -37,14 +37,36 @@ namespace JUI
|
||||
|
||||
/// Tree system
|
||||
|
||||
JUI::Rect* CreateFileEntry(const std::string& name) {
|
||||
JUI::Rect* CreateFileEntry(const std::filesystem::directory_entry& entry) {
|
||||
auto* rect = new JUI::TextRect(file_layout);
|
||||
rect->Size({100_percent, 20_px});
|
||||
|
||||
|
||||
std::string entry_type = entry.is_directory() ? "directory" : "file";
|
||||
std::string perms = stringify(entry.status().permissions());
|
||||
std::string type = stringify(entry.status().type());
|
||||
|
||||
auto file_size = (entry.is_directory() ? entry.file_size() : 0 );
|
||||
|
||||
std::string label = std::format("{} {} {} {} {}", entry.path().filename().string(), entry.file_size(), perms, entry.last_write_time(), type);
|
||||
|
||||
rect->Content(entry.path().filename());
|
||||
|
||||
|
||||
if (entry.is_directory()) {
|
||||
|
||||
}
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
|
||||
FileDialogWindow(const std::filesystem::path& root) : FileDialogWindow() {
|
||||
std::cout << root.relative_path() << std::endl;
|
||||
std::cout << root.root_directory() << std::endl;
|
||||
for (const auto& entry: std::filesystem::directory_iterator(root)) {
|
||||
std::cout << entry.path().filename() << std::endl;
|
||||
|
||||
CreateFileEntry(entry);
|
||||
}
|
||||
}
|
||||
explicit FileDialogWindow(Widget* parent, const std::filesystem::path& root) : FileDialogWindow(root)
|
||||
|
Reference in New Issue
Block a user