mirror of
https://github.com/mauiaaron/apple2.git
synced 2024-06-08 16:29:27 +00:00
Make sure data_dir and logging are initialized for all platforms
This commit is contained in:
parent
27a848f61b
commit
36c83c62e3
|
@ -119,9 +119,12 @@
|
|||
NSString *disks[] = { @"disks", @"external-disks", NULL};
|
||||
|
||||
NSString **str = &disks[0];
|
||||
assert(data_dir == NULL);
|
||||
while (*str) {
|
||||
NSString *apple2ixDirString = [documentsDir stringByAppendingPathComponent:apple2ix];
|
||||
data_dir = strdup([apple2ixDirString UTF8String]);
|
||||
if (data_dir == NULL) {
|
||||
data_dir = STRDUP([apple2ixDirString UTF8String]);
|
||||
}
|
||||
|
||||
NSString *documentsPath = [apple2ixDirString stringByAppendingPathComponent:*str];
|
||||
NSString *resourcesPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:*str];
|
||||
|
|
|
@ -91,6 +91,7 @@ GLenum safeGLGetError(void) {
|
|||
#endif
|
||||
|
||||
void log_init(void) {
|
||||
assert(data_dir);
|
||||
_log_rotate(/*performRotation:*/false);
|
||||
}
|
||||
|
||||
|
|
17
src/misc.c
17
src/misc.c
|
@ -37,9 +37,23 @@ int argc = 0;
|
|||
const char *locale = NULL;
|
||||
CrashHandler_s *crashHandler = NULL;
|
||||
|
||||
#if defined(CONFIG_DATADIR)
|
||||
static void _init_common(void) {
|
||||
|
||||
#if defined(CONFIG_DATADIR)
|
||||
assert(!data_dir);
|
||||
data_dir = STRDUP(CONFIG_DATADIR PATH_SEPARATOR PACKAGE_NAME);
|
||||
#elif MOBILE_DEVICE
|
||||
// data_dir handled elsewhere ...
|
||||
#else
|
||||
assert(!data_dir);
|
||||
char buf[PAGE_SIZE];
|
||||
snprintf(buf, PAGE_SIZE, "%s/.apple2", HOMEDIR);
|
||||
data_dir = STRDUP(buf);
|
||||
#endif
|
||||
assert(data_dir);
|
||||
|
||||
mkdir(data_dir, (S_IRWXU|S_IRWXG));
|
||||
|
||||
log_init();
|
||||
srandom((unsigned int)time(NULL));
|
||||
LOG("Initializing common...");
|
||||
|
@ -49,6 +63,7 @@ static __attribute__((constructor)) void __init_common(void) {
|
|||
emulator_registerStartupCallback(CTOR_PRIORITY_FIRST, &_init_common);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_DATADIR)
|
||||
static void _cli_help(void) {
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "Usage: %s [-A <audio>] [-V <video>]\n", argv[0]);
|
||||
|
|
Loading…
Reference in New Issue
Block a user