Skip to content

build/api-examples/NativeFile.cpp

Complete program from the NativeFile API reference. Save it at the path shown above and use the build command in the reference page.

Source files · Download NativeFile.cpp

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

int main()
{
    gaspardos::NativeFile file;
    if (file.open(L"\\AHCIDISK0\\readme.txt", GO64_RDONLY) < 0)
        return 1;
    char    data[128];
    int64_t count  = file.read(data, sizeof(data));
    int64_t closed = file.close();
    return count >= 0 && closed == 0 ? 0 : 1;
}