![]() |
LibGame v0.4.0
The LG Game Engine - Copyright (C) 2024-2026 ETMSoftware
|
Functions | |
| void * | lg_open_file (const char *full_path, const char *mode_str) |
| long long | lg_get_file_size (const char *full_path) |
| int | lg_read_from_bfile (const char *full_path, void *data, size_t size) |
| int | lg_write_to_bfile (const char *full_path, void *data, size_t size) |
| void | lg_close_file (FILE *fp) |
| void * | lg_open_android_asset (const char *relative_path, const char *unused) |
| long long | lg_get_android_asset_size (const char *relative_path) |
| int | lg_read_from_android_asset (const char *relative_path, void *data, size_t size) |
| void | lg_close_android_asset (void *rwops) |
| zboolean | lg_copy_file_from_app_wr_to_assets (const char *file_name, const char *src_sub_path, const char *dest_sub_path) |
| zboolean | lg_copy_file_from_cache_to_assets (const char *file_name, const char *src_sub_path, const char *dest_sub_path) |
| char * | lg_getline_from_str (const char *str) |
On Android, assets are included in the APK, and very often compressed.
So now, when trying to read assets, we can fallback to *_android_asset_*() funcs which use SDL_RWops funcs.
See these macros in lg_file_ops.h, and DO use them whenever you need to access ASSETS:
OPEN_ASSET_FILE GET_ASSET_SIZE READ_ASSET_FILE CLOSE_ASSET_FILE
(Or we'll try android_fopen.c/h ?)
NEW CONVENTIONS FOR PATHS / FILE NAMES AS FUNC ARGS:
| void * lg_open_file | ( | const char * | full_path, |
| const char * | mode_str | ||
| ) |
Open file in specified mode (see fopen modes)
| full_path | Full path to file |
| mode_str | Opening mode |
| long long lg_get_file_size | ( | const char * | full_path | ) |
Get file size
| full_path | Full path to file |
| int lg_read_from_bfile | ( | const char * | full_path, |
| void * | data, | ||
| size_t | size | ||
| ) |
Read from binary file
To read full content, just get file size first with lg_get_file_size()
| full_path | Full path to file |
| data | A pointer to a buffer |
| size | Num of bytes to read |
| int lg_write_to_bfile | ( | const char * | full_path, |
| void * | data, | ||
| size_t | size | ||
| ) |
Write to binary file
| full_path | Full path to file |
| data | A pointer to a buffer |
| size | Num of bytes to write |
| void lg_close_file | ( | FILE * | fp | ) |
Close opened stream
| void * lg_open_android_asset | ( | const char * | relative_path, |
| const char * | unused | ||
| ) |
Open Android asset in "rb" mode (see fopen modes)
| relative_path | Relative path to file in Android app's assets |
| unused | Unused, only there for compatibility with lg_open_file() |
| long long lg_get_android_asset_size | ( | const char * | relative_path | ) |
Get Android asset size
| relative_path | Relative path to file in Android app's assets |
| int lg_read_from_android_asset | ( | const char * | relative_path, |
| void * | data, | ||
| size_t | size | ||
| ) |
Read from Android asset
To read full content, just get file size first with lg_get_android_asset_size()
| relative_path | Relative path to file in Android app's assets |
| data | A pointer to a buffer |
| size | Num of bytes to read |
| void lg_close_android_asset | ( | void * | rwops | ) |
Close opened Android asset
| rwops |
| zboolean lg_copy_file_from_app_wr_to_assets | ( | const char * | file_name, |
| const char * | src_sub_path, | ||
| const char * | dest_sub_path | ||
| ) |
Copy file from the SRC SUB PATH folder in the APP WRITABLE folder to the DEST SUB PATH folder in assets
NO-OP on Android
| file_name | Should be file basename |
| src_sub_path | Sub path int the assets folder |
| dest_sub_path | Sub path int the APP WRITABLE folder |
| zboolean lg_copy_file_from_cache_to_assets | ( | const char * | file_name, |
| const char * | src_sub_path, | ||
| const char * | dest_sub_path | ||
| ) |
Copy file from the SUB PATH folder in the LG_APP_CACHE folder to the SUB PATH folder in assets
NO-OP on Android
| file_name | Should be file basename |
| src_sub_path | Sub path int the assets folder |
| dest_sub_path | Sub path int the APP WRITABLE folder |
| char * lg_getline_from_str | ( | const char * | str | ) |
Read an entire line from a string, ie until reaching end of line char ('
')
Behave almost like getline() but: - Read from a null-terminated string - Returned string must be freed after each call
| str | A null-terminated string |