![]() |
LibGame
v0.4.0
The LG Game Engine - Copyright (C) 2024-2025 ETMSoftware
|
Functions | |
| void * | lg_open_file (const char *path, const char *mode_str) |
| long long | lg_get_file_size (const char *path) |
| int | lg_read_from_bfile (const char *path, void *data, size_t size) |
| int | lg_write_to_bfile (const char *path, void *data, size_t size) |
| void | lg_close_file (FILE *fp) |
| void * | lg_open_android_asset (const char *path, const char *unused) |
| long long | lg_get_android_asset_size (const char *path) |
| int | lg_read_from_android_asset (const char *path, void *data, size_t size) |
| void | lg_close_android_asset (void *rwops) |
| 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 ?)
| void* lg_open_file | ( | const char * | path, |
| const char * | mode_str | ||
| ) |
Open file in specified mode (see fopen modes)
| path | Path to file |
| mode_str | Opening mode |
| long long lg_get_file_size | ( | const char * | path | ) |
Get file size
| path | Path to file |
| int lg_read_from_bfile | ( | const char * | path, |
| void * | data, | ||
| size_t | size | ||
| ) |
Read from binary file
To read full content, just get file size first with lg_get_file_size()
| path | Path to file |
| data | A pointer to a buffer |
| size | Num of bytes to read |
| int lg_write_to_bfile | ( | const char * | path, |
| void * | data, | ||
| size_t | size | ||
| ) |
Write to binary file
| path | 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 * | path, |
| const char * | unused | ||
| ) |
Open Android asset in "rb" mode (see fopen modes)
| path | Path to file |
| unused | Unused, only there for compatibility with lg_open_file() |
| long long lg_get_android_asset_size | ( | const char * | path | ) |
Get Android asset size
| path | Path to file |
| int lg_read_from_android_asset | ( | const char * | 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()
| path | Path to file |
| data | A pointer to a buffer |
| size | Num of bytes to read |
| void lg_close_android_asset | ( | void * | rwops | ) |
Close opened Android asset
| rwops |
| 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 |