C++ class: FileExplorer¶
Description¶
Noncopyable navigation and path selection model.
Qualified name : gaspardos::desktop::FileExplorer.
Header : bindings/cpp/file_explorer.hpp. C++98.
When to use it¶
Select a file, destination or folder independently of rendering.
Simple program example¶
#include "desktop_native.hpp"
#include <cstdio>
#include <cstring>
int main()
{
gaspardos::desktop::NativeFileAccess access;
gaspardos::desktop::FileExplorer explorer(access);
explorer.begin(gaspardos::desktop::FileExplorer::SelectFolder, "/AHCIDISK0");
for (unsigned i = 0; i < 10000 && explorer.loading(); ++i)
{
explorer.tick();
GO64_yield();
}
if (explorer.loading() || !explorer.accept(""))
return 1;
return explorer.accepted() ? 0 : 1;
}
Building from Windows¶
Save the program above as build/api-examples/FileExplorer.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/FileExplorer.cpp build/api-examples/syscall.o bindings/cpp/file_explorer.cpp bindings/cpp/desktop_native.cpp -o build/api-examples/FileExplorer-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 FileExplorer(FileAccess& access)¶
Keep a backend reference.
void begin(Mode mode, const std::string& initial, bool overwrite = false)¶
OpenFile/SaveFile/SelectFolder mode, initial path, overwrite disabled by default.
bool navigate(const std::string& directory)¶
Request directory loading; false when rejected.
bool tick()¶
Advance loading from the parent loop.
void select(int index)¶
Select a list index.
void activate(int index)¶
Enter a directory or activate the selected file.
bool accept(const std::string& name)¶
Validate name for this mode; SaveFile may require a second confirmation.
bool createFolder(const std::string& name)¶
Validate the name, then create a directory.
void cancel()¶
Finish without accepting.
const std::vector<FileEntry>& entries() const¶
Reference to current entries; navigation/tick may invalidate it.
const std::string& directory() const¶
Current path.
const std::string& result() const¶
Selected path; check accepted before use.
bool loading() const¶
Loading in progress.
bool finished() const¶
Model interaction finished.
bool accepted() const¶
Result accepted.
bool confirming() const¶
Overwrite confirmation pending.
int selected() const¶
Selected index or negative sentinel.
Mode mode() const¶
Active mode.
Public data¶
volumes : vector
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.