al_android_open_fd(3)

al_android_open_fd3

Allegro 5 api

Usage

#include <allegro5/allegro_android.h>
int al_android_open_fd(const char *uri, const char *mode)

Overview

Opens a file descriptor to access data under a Universal Resource Identifier (URI). This function accepts content:// and file:// URI schemes. You are responsible for closing the returned file descriptor.

The file mode can be "r", "w", "rw", "wt", "wa" or "rwt". The exact implementation of these modes differ depending on the underlying content provider. For example, "w" may or may not truncate.

Returns a file descriptor on success or a negative value on an error. On an error, the Allegro errno is set.

Note: Remember to add to your manifest file the relevant permissions to your app.

Example:

const char *content_uri = "content://...";
int fd = al_android_open_fd(content_uri, "r");
if (fd >= 0) {
    ALLEGRO_FILE *f = al_fopen_fd(fd, "r");
    if (f != NULL) {
        do_something_with(f);
        al_fclose(f);
    }
    else {
        handle_error(al_get_errno());
        close(fd);
    }
}
else {
    handle_error(al_get_errno());
}

Since

5.2.10

From allegro 5.2.11.3-2 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.