Loading...
Searching...
No Matches
CAPI_FileSystem.h File Reference

Overview

User-defined file system interface.

#include <Ultralight/CAPI/CAPI_FileSystem.h>

The library uses this to load file data (ie, raw file bytes) for a given file URL (eg, file:///page.html) .

You can provide the library with your own FileSystem implementation (ULFileSystem) so that file data is provided directly by your application (eg, from memory, from a virtual file system, etc).

See also
ulPlatformSetFileSystem

Classes

struct  ULFileSystem
 User-defined file system interface. More...
 

Typedefs

typedef bool(* ULFileSystemFileExistsCallback) (ULString path)
 The callback invoked when the FileSystem wants to check if a file path exists, return true if it exists.
 
typedef ULString(* ULFileSystemGetFileMimeTypeCallback) (ULString path)
 Get the mime-type of the file (eg "text/html").
 
typedef ULString(* ULFileSystemGetFileCharsetCallback) (ULString path)
 Get the charset / encoding of the file (eg "utf-8").
 
typedef ULBuffer(* ULFileSystemOpenFileCallback) (ULString path)
 Open file for reading and map it to a Buffer.
 

Typedef Documentation

◆ ULFileSystemFileExistsCallback

typedef bool(* ULFileSystemFileExistsCallback) (ULString path)

The callback invoked when the FileSystem wants to check if a file path exists, return true if it exists.

◆ ULFileSystemGetFileCharsetCallback

typedef ULString(* ULFileSystemGetFileCharsetCallback) (ULString path)

Get the charset / encoding of the file (eg "utf-8").

This is only important for text-based files and is usually determined by analyzing the contents of the file.

If a charset cannot be determined, it's usually safe to return "utf-8" for this value.

The library will consume the result and call ulDestroyString() after this call returns.

◆ ULFileSystemGetFileMimeTypeCallback

typedef ULString(* ULFileSystemGetFileMimeTypeCallback) (ULString path)

Get the mime-type of the file (eg "text/html").

This is usually determined by analyzing the file extension.

If a mime-type cannot be determined, you should return "application/unknown" for this value.

The library will consume the result and call ulDestroyString() after this call returns.

◆ ULFileSystemOpenFileCallback

typedef ULBuffer(* ULFileSystemOpenFileCallback) (ULString path)

Open file for reading and map it to a Buffer.

To minimize copies, you should map the requested file into memory and use ulCreateBuffer() to wrap the data pointer (unmapping should be performed in the destruction callback).

If the file was unable to be opened, you should return NULL for this value.

Go to the source code of this file.