mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-12 00:56:40 -04:00
iOS: Store most things in documents instead of application support folder for greater visibility to the user, and store all cached textures inside Application Storage/Cache folder instead so that iOS doesn't back them up and will remove them when running low on disk space if required
See https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html for more details
This commit is contained in:
parent
a0536fc460
commit
f9fde77e12
@ -143,9 +143,13 @@ cc_uint64 Stopwatch_Measure(void) {
|
||||
/*########################################################################################################################*
|
||||
*-----------------------------------------------------Directory/File------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
#if defined CC_BUILD_IOS
|
||||
/* implemented in interop_ios.m */
|
||||
#else
|
||||
void Directory_GetCachePath(cc_string* path, const char* folder) {
|
||||
String_AppendConst(path, folder);
|
||||
}
|
||||
#endif
|
||||
|
||||
cc_result Directory_Create(const cc_string* path) {
|
||||
char str[NATIVE_STR_LEN];
|
||||
|
@ -709,7 +709,7 @@ int Platform_GetCommandLineArgs(int argc, STRING_REF char** argv, cc_string* arg
|
||||
|
||||
cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) {
|
||||
// https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html
|
||||
NSArray* array = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
|
||||
NSArray* array = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
||||
if (array.count <= 0) return ERR_NOT_SUPPORTED;
|
||||
|
||||
NSString* str = [array objectAtIndex:0];
|
||||
@ -743,6 +743,22 @@ void GetDeviceUUID(cc_string* str) {
|
||||
String_AppendUtf8(str, src, String_Length(src));
|
||||
}
|
||||
|
||||
void Directory_GetCachePath(cc_string* path, const char* folder) {
|
||||
NSArray* array = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
|
||||
if (array.count > 0) {
|
||||
// try to use iOS app cache folder if possible
|
||||
// https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html
|
||||
NSString* str = [array objectAtIndex:0];
|
||||
const char* utf8 = [str UTF8String];
|
||||
|
||||
String_AppendUtf8(path, utf8, String_Length(utf8));
|
||||
String_Format1(path, "/%c", folder);
|
||||
Directory_Create(path);
|
||||
} else {
|
||||
String_AppendConst(path, folder);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-----------------------------------------------------Font handling-------------------------------------------------------*
|
||||
|
Loading…
x
Reference in New Issue
Block a user