Added ExtractArchive function,some Android support
This commit is contained in:
parent
7655e74648
commit
0ab42314e1
29
src/core.c
29
src/core.c
|
|
@ -301,6 +301,9 @@
|
|||
#define STORAGE_DATA_FILE "storage.data"
|
||||
#endif
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Types and Structures Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
@ -1248,8 +1251,10 @@ const char *GetOS(void)
|
|||
|
||||
void Execute(const char *command)
|
||||
{
|
||||
#ifdef __ANDROID__ || TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR || TARGET_OS_EMBEDDED
|
||||
#ifdef || TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR || TARGET_OS_EMBEDDED
|
||||
return -1;
|
||||
#elif __ANDROID__
|
||||
if (fork() == 0) return system(command);
|
||||
#else
|
||||
return system(command);
|
||||
#endif
|
||||
|
|
@ -2247,7 +2252,7 @@ long GetFileModTime(const char *fileName)
|
|||
}
|
||||
|
||||
// Downloads a file from source (URL) to directory
|
||||
// NOTES: It uses cURL
|
||||
// NOTES: It uses cURL,Also this function won't works in Android
|
||||
void DownloadFile(const char *src,const char *dir)
|
||||
{
|
||||
#ifdef __ANDROID__ || TARGET_OS_IPHONE || TARGET_OS_EMBEDDED || TARGET_IPHONE_SIMULATOR
|
||||
|
|
@ -2287,6 +2292,26 @@ unsigned char *DecompressData(unsigned char *compData, int compDataLength, int *
|
|||
return (unsigned char *)data;
|
||||
}
|
||||
|
||||
// Extracts an archive,Uses 7z on Windows,unzip on other platforms
|
||||
// NOTES: You might need busybox or termux on android to get this function work
|
||||
void ExtractArchive(const char *archivepath) {
|
||||
#ifdef TARGET_OS_IPHONE || TARGET_OS_EMBEDDED || TARGET_IPHONE_SIMULATOR
|
||||
return -1;
|
||||
#elif __ANDROID__
|
||||
if (fork() == 0) {
|
||||
if (system("unzip") == 0) {
|
||||
system(FormatText("unzip %s", archivepath));
|
||||
} else return -1;
|
||||
} else return -1;
|
||||
#elif _WIN32 || _WIN64
|
||||
if (system("7z") == 0) system(FormatText("7z e %s", archivepath));
|
||||
else return -1;
|
||||
#else
|
||||
if (system("unzip") == 0) system(FormatText("unzip %s", archivepath));
|
||||
else return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Save integer value to storage file (to defined position)
|
||||
// NOTE: Storage positions is directly related to file memory layout (4 bytes each integer)
|
||||
void SaveStorageValue(unsigned int position, int value)
|
||||
|
|
|
|||
|
|
@ -1101,6 +1101,7 @@ RLAPI void DownloadFile(const char *src,const char *dir); // Downloads a
|
|||
|
||||
RLAPI unsigned char *CompressData(unsigned char *data, int dataLength, int *compDataLength); // Compress data (DEFLATE algorythm)
|
||||
RLAPI unsigned char *DecompressData(unsigned char *compData, int compDataLength, int *dataLength); // Decompress data (DEFLATE algorythm)
|
||||
RLAPI void ExtractArchive(const char *archivepath); // Extracts archive
|
||||
|
||||
// Persistent storage management
|
||||
RLAPI void SaveStorageValue(unsigned int position, int value); // Save integer value to storage file (to defined position)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user