![]() |
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) |
| ssize_t | lg_get_file_size (const char *full_path) |
| int | lg_read_from_bfile (const char *full_path, void *data, size_t size) |
| int | lg_read_from_bfile2 (const char *full_path, void *data, int64_t *size2) |
| int | lg_write_to_bfile (const char *full_path, const void *data, size_t size) |
| void | lg_close_file (FILE *fp) |
| void * | lg_open_asset_file (const char *relative_path_in_assets, const char *unused) |
| int64_t | lg_get_asset_file_size (const char *relative_path_in_assets) |
| int | lg_read_from_asset_file (const char *relative_path_in_assets, void *data, size_t size) |
| int | lg_read_from_asset_file2 (const char *relative_path_in_assets, void *data, int64_t *size2) |
| void | lg_close_asset_file (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) |
NOTE: The SDL_RWops API doesn't deal with compressed assets so make sure to put this in APP_NAME/app/build.gradle:
androidResources {
noCompress "scene", "txt", "obj", "fbx", "bmesh", "png", "jpg", "pkm", "ttf", "ogg", "wav"
}
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 |
| ssize_t 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 - need data size
To read full content, just get file size first with lg_get_file_size()
| full_path | Full path to file |
| data | Pointer to a buffer |
| size | Num of bytes to read |
| int lg_read_from_bfile2 | ( | const char * | full_path, |
| void * | data, | ||
| int64_t * | size2 | ||
| ) |
Read from binary file - variant 2: no need to get file size first
| full_path | Full path to file |
| data | Pointer to a buffer |
| size2 | Pointer to an int64_t which will get the num of bytes read |
| int lg_write_to_bfile | ( | const char * | full_path, |
| const void * | data, | ||
| size_t | size | ||
| ) |
Write to binary file
| full_path | Full path to file |
| data | Pointer to a buffer |
| size | Num of bytes to write |
| void lg_close_file | ( | FILE * | fp | ) |
Close opened stream
| void * lg_open_asset_file | ( | const char * | relative_path_in_assets, |
| const char * | unused | ||
| ) |
Open file in app's ASSETS dir in "rb" mode (see fopen modes)
WARNING: the SDL_RWops API doesn't deal with compressed assets so make sure to put this in APP_NAME/app/build.gradle:
| relative_path_in_assets | Relative path to file in app's ASSETS dir |
| unused | Unused, only there for compatibility with lg_open_file() |
| int64_t lg_get_asset_file_size | ( | const char * | relative_path_in_assets | ) |
Get size of file in app's ASSETS dir
| relative_path_in_assets | Relative path to file in app's ASSETS dir |
| int lg_read_from_asset_file | ( | const char * | relative_path_in_assets, |
| void * | data, | ||
| size_t | size | ||
| ) |
Read from file in app's ASSETS dir - need data size
To read full content, just get file size first with lg_get_asset_file_size()
| relative_path_in_assets | Relative path to file in app's ASSETS dir |
| data | Pointer to a buffer |
| size | Num of bytes to read |
| int lg_read_from_asset_file2 | ( | const char * | relative_path_in_assets, |
| void * | data, | ||
| int64_t * | size2 | ||
| ) |
Read from file in app's ASSETS dir - variant 2: no need to get file size first
| relative_path_in_assets | Relative path to file in app's ASSETS dir |
| data | Pointer to a buffer |
| size2 | Pointer to an int64_t which will get the num of bytes read, or -1 on error |
| void lg_close_asset_file | ( | void * | rwops | ) |
Close opened file in app's ASSETS dir
| 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 |