Skip to content

C++ class: DirectoryListing

Index · Français

Description

Noncopyable incremental directory loader.

Qualified name : gaspardos::desktop::DirectoryListing.

Header : bindings/cpp/file_explorer.hpp. C++98.

When to use it

Keep the UI loop responsive while reading a directory.

Simple program example

#include "desktop_native.hpp"
#include <cstdio>
#include <cstring>

int main()
{
    gaspardos::desktop::NativeFileAccess access;
    gaspardos::desktop::DirectoryListing listing(access);
    if (!listing.begin("/AHCIDISK0"))
        return 1;
    for (unsigned i = 0; i < 10000 && listing.loading; ++i)
    {
        listing.tick();
        GO64_yield();
    }
    return !listing.loading && listing.error == 0 ? 0 : 1;
}

Building from Windows

Save the program above as build/api-examples/DirectoryListing.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/DirectoryListing.cpp build/api-examples/syscall.o bindings/cpp/file_explorer.cpp bindings/cpp/desktop_native.cpp -o build/api-examples/DirectoryListing-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 DirectoryListing(FileAccess& access)

Keep a backend reference; backend must outlive the listing.

~DirectoryListing()

Cancel and attempt closure.

bool begin(const std::string& path)

Start reading path; boolean startup success.

bool tick()

Advance work with a 16-entry budget; inspect loading and error for state.

void cancel()

Stop reading and attempt to close the handle.

Public data

entries : vector ; loading : bool ; error : int64_t. Limites / limits: 4096 entries, ~1 MiB names/paths.

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.