C++ class: FileDialog¶
Description¶
File dialog embedded in the parent window.
Qualified name : gaspardos::desktop::FileDialog.
Header : bindings/cpp/desktop_gui.hpp. C++98.
When to use it¶
Select a path without blocking other application work.
Simple program example¶
#include "desktop_gui.hpp"
#include <cstdio>
#include <cstring>
int main()
{
gaspardos::desktop::NativeFileAccess access;
gaspardos::desktop::FileDialog dialog(access);
dialog.begin(gaspardos::desktop::FileExplorer::OpenFile, "/AHCIDISK0");
GO64_Event event = {};
event.type = 8;
event.key = 27;
dialog.event(event, 0);
return !dialog.active() && !dialog.accepted() ? 0 : 1;
}
Building from Windows¶
Save the program above as build/api-examples/FileDialog.cpp from the repository root. Create the directory if necessary.
PowerShell — from the repository root:
New-Item -ItemType Directory -Force build/api-examples | Out-Null
& .\build-x64-install\bin\x86_64-gaspardos-gcc.exe -std=gnu1x -O2 -mno-red-zone -c bindings/native/gaspardos_x64_syscall.c -o build/api-examples/syscall.o
if ($LASTEXITCODE -ne 0) { throw "C compilation failed" }
& .\build-x64-install\bin\x86_64-gaspardos-g++.exe -std=c++98 -O2 -Ibindings/cpp build/api-examples/FileDialog.cpp build/api-examples/syscall.o bindings/cpp/file_explorer.cpp bindings/cpp/desktop_native.cpp bindings/cpp/desktop_gui.cpp -o build/api-examples/FileDialog-x64.elf
if ($LASTEXITCODE -ne 0) { throw "C++ compilation/link failed" }
Run the ELF on GaspardOS, not Windows. The driver supplies CRT and libraries. Prepare the required volumes/services; examples bound their waits and may exit on backpressure rather than retry. Successful compilation does not validate kernel execution.
The headers, implementation files, native wrappers and complete examples are available under Source files.
Class methods¶
explicit FileDialog(FileAccess& access)¶
Backend retained by reference; must outlive dialog.
void begin(FileExplorer::Mode mode, const std::string& initial, const std::string& suggested = "", bool allowOverwrite = false)¶
Mode, directory, suggested name, overwrite permission; 1000 × 700 parent surface.
void event(const GO64_Event& event, uint64_t ticks)¶
Forward event and monotonic ticks; reserve input for the active dialog.
void tick()¶
Advance incremental loading; call each iteration.
int64_t paint(gui::Painter& painter)¶
Draw through Painter after READY; -11 requests a later retry.
bool active() const¶
Interaction still active.
bool accepted() const¶
True only after accepted closure; does not save the file.
const std::string& result() const¶
Selected UTF-8 path, use only if accepted.
Native contract¶
LP64 ABI, 32-bit wchar_t, no packing. Native negative results are not errno. Handle -11 with yield and an application limit. Referenced objects must outlive their users; do not copy handle owners. File uses stdio/errno and invalidates its stream on close, even on error.