Testing more of the filesystem API

This commit is contained in:
2025-06-26 21:45:35 -05:00
parent dca15511ea
commit ce0c69190a
2 changed files with 25 additions and 5 deletions

View File

@@ -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)

View File

@@ -42,7 +42,6 @@
using namespace JUI;
float ui_scale = 1.f;
float accum = 0;
int iter = 0;
@@ -201,7 +200,6 @@ JUI::UtilityBar* CreateUtilityBar(JUI::Widget* root) {
});
}
auto* help = topbar->AddButton("About", [&] {
});