al_android_open_fd(3)

NAME

al_android_open_fd - Allegro 5 API

SYNOPSIS

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

DESCRIPTION

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

SEE ALSO

al_fopen_fd(3), al_get_errno(3)

    [Unstable API]: This API is new and subject to refinement.