The fsIOOpenRead function is used to open a file and read data from it.

Syntax
FsIOFile fsIOOpenRead(
    const char* path,
    FsIOOpenFlags flags,
    char* outBuffer,
    int byteOffset,
    int byteToRead,
    FsIOFileReadCallback callback,
    void* pUserData
);
Members
ParametersDescription
pathPath to the file being opened for reading. Files must exist within the package using the module to be able to be read, however please note that some files may be encrypted or inaccessible, as explained here: Inaccessible FilesYou can use the following to target files from the package folder root or the persistent storage root:./ - to access the files from within the add-on package, eg: ./data/pi.txt. The path will look for the pi.txt file in the data folder from the package root in the VFS./work/ - to access a persistent storage that the add-on can use, eg: /work/pi.txt. The path will look in the persistent storage folder for the pi.txt file. This file is located here: %appdata%/Microsoft Flight Simulator/WASM/MSFS2020/PackageName/work
flagsThis is a bit-flag defining how the file should be opened. Please see FsIOOpenFlags for details.
outBufferThis is a pointer to a previously created buffer which will store the data being read. It needs to be allocated and must be large enough to contain the whole file or the byteToRead bytes (if not set to -1).
byteOffsetThis is the offset into the file from which data will be read. If this is not null then byteToRead must not be set to -1.
byteToReadThis defines the number of bytes to read from the file. If set to -1, the entire file will be read.
callbackCallback (FsIOFileReadCallback) that is sent when the open operation is finished.
pUserDataPointer given to the callback to identify the function call.
Return Values

An ID pointer representing the file being opened.

Remarks

This function is non-blocking: it will not wait for the file to be opened to pass to the next line of code. Errors can be checked for using the fsIOGetLastError function.

0/255