File API
Declared by <huxerui/file.h>.
Results and metadata
Section titled “Results and metadata”FileType:File,Directory,Other.FileInfo: type, byte size, optional modification time.FileErrorCode:NotFound,PermissionDenied,NotDirectory,IsDirectory,TooLarge,InvalidEncoding,Unsupported,Io.FileError: code and message.FileResult<T>: construct from value/error;Succeeded, ref-qualifiedValue, andErroraccessors.
Construct from UTF-8 path/string view or parent plus child. Path queries: Path, Name, Stem, Extension, ParentPath, Parent, Child, and Resolve. Status queries: Exists, IsFile, IsDirectory, synchronous/async Stat.
I/O methods have synchronous and Async forms: read bytes/string; write and append bytes/string; list children; create one/all directories; delete or recursively delete; copy; and move. Copy/move accept overwrite = false. Async methods return Task.
FileReference
Section titled “FileReference”Capability for a selected or activated file. Metadata: Name, optional Size, optional ContentType, CanWrite. Async operations: ReadBytesAsync, ReadStringAsync, ImportToAsync, and ReplaceWithAsync.
FilePicker
Section titled “FilePicker”FilePickerFilter contains name, extensions, and content types. SaveFileOptions contains suggested name and filter. Capability queries are CanOpenFiles and CanSaveFiles; operations are OpenFileAsync, OpenFilesAsync, and SaveFileAsync.
FileSystem
Section titled “FileSystem”AppDirectories contains optional executable directory plus required data, cache, and temporary directories. FileSystem::Directories() returns them; CurrentDirectory() resolves process working directory. Obtain FileSystem and FilePicker with UseService<T>().
Complete picker example
Section titled “Complete picker example”#include <huxerui/huxerui.h>
using namespace huxerui;
Task<void> OpenText(State<std::string> content) { auto picker = UseService<FilePicker>(); auto selected = co_await picker->OpenFileAsync({ .name = "Text", .extensions = {"txt"}, .content_types = {"text/plain"}, }); if (!selected) { co_return; } auto text = co_await selected->ReadStringAsync(); if (text.Succeeded()) { content = std::move(text).Value(); }}Cancellation is represented by an empty optional. A returned FileReference preserves provider authority without inventing a local path.

