- A bridge between Java and C for android assets manager.
- Full usage: usage.c
Creates and returns a new android_assets_manager instance.
- Parameters: None
- Returns: struct android_assets_manager* or NULL on failure
Example:
struct android_assets_manager* manager = android_assets_manager_new();Closes and frees the manager instance.
- Parameters:
- manager: pointer to the manager instance
Example:
android_assets_manager_close(manager);Reads a UTF-8 text file from the assets/ directory.
- Parameters:
- filename: relative path to the asset file
- Returns: char* containing null-terminated string, or NULL on failure
- Note: You must free the returned pointer using free().
Example:
char* content = manager->read_text_file("data/config.json");
if (content) {
puts(content);
free(content);
}Reads a binary file from the assets/ directory.
- Parameters:
- filename: relative path to the asset file
- Returns: struct int8_array_t* or NULL on failure
(with data and len fields)
Example:
struct int8_array_t* bin = manager->read_bin_file("game.bin");
if (bin) {
// Use bin->data and bin->len
free(bin->data);
free(bin);
}Checks whether the given file exists in the assets/ directory.
- Parameters:
- filename: relative path to the file
- Returns: true if the file exists, false otherwise
Example:
if (manager->file_exists("readme.txt")) {
// File exists
}Lists the files in a given directory inside assets/.
- Parameters:
- directory: path to the directory inside assets (with trailing slash)
- out_count: pointer to receive the number of entries
- Returns: char** array of filenames, or NULL on failure
Example:
size_t count;
char** files = manager->list_files("textures/", &count);
if (files) {
for (size_t i = 0; i < count; ++i) {
printf("File: %s\\n", files[i]);
}
manager->free_file_list(files, count);
}Frees the memory allocated by list_files().
- Parameters:
- list: the list returned by list_files()
- count: the number of elements
Example:
manager->free_file_list(files, count);