annotate paths.c @ 1489:637fbc3b5063 nuklear_ui

Added code to persist config back to a file
author Michael Pavone <pavone@retrodev.com>
date Wed, 29 Nov 2017 08:41:37 -0800
parents 77a401044935
children b96f9fae757f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1473
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #include <string.h>
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
2 #include <stdlib.h>
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
3 #include "blastem.h"
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
4 #include "util.h"
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
5
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
6 static char **current_path;
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
7
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
8 static void persist_path(void)
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
9 {
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
10 char const *parts[] = {get_userdata_dir(), PATH_SEP, "sticky_path"};
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
11 char *pathfname = alloc_concat_m(3, parts);
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
12 FILE *f = fopen(pathfname, "wb");
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
13 if (f) {
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
14 if (fwrite(*current_path, 1, strlen(*current_path), f) != strlen(*current_path)) {
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
15 warning("Failed to save menu path");
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
16 }
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
17 fclose(f);
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
18 } else {
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
19 warning("Failed to save menu path: Could not open %s for writing\n", pathfname);
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
20
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
21 }
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
22 free(pathfname);
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
23 }
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
24
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
25 #ifdef __ANDROID__
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
26 #include <SDL.h>
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
27 #include <jni.h>
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
28 static char *get_external_storage_path()
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
29 {
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
30 static char *ret;
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
31 if (ret) {
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
32 return ret;
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
33 }
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
34 JNIEnv *env = SDL_AndroidGetJNIEnv();
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
35 if ((*env)->PushLocalFrame(env, 8) < 0) {
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
36 return NULL;
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
37 }
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
38
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
39 jclass Environment = (*env)->FindClass(env, "android/os/Environment");
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
40 jmethodID getExternalStorageDirectory =
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
41 (*env)->GetStaticMethodID(env, Environment, "getExternalStorageDirectory", "()Ljava/io/File;");
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
42 jobject file = (*env)->CallStaticObjectMethod(env, Environment, getExternalStorageDirectory);
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
43 if (!file) {
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
44 goto cleanup;
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
45 }
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
46
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
47 jmethodID getAbsolutePath = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, file),
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
48 "getAbsolutePath", "()Ljava/lang/String;");
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
49 jstring path = (*env)->CallObjectMethod(env, file, getAbsolutePath);
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
50
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
51 char const *tmp = (*env)->GetStringUTFChars(env, path, NULL);
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
52 ret = strdup(tmp);
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
53 (*env)->ReleaseStringUTFChars(env, path, tmp);
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
54
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
55 cleanup:
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
56 (*env)->PopLocalFrame(env, NULL);
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
57 return ret;
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
58 }
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
59 #endif
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
60
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
61 void get_initial_browse_path(char **dst)
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
62 {
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
63 *dst = NULL;
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
64 char *remember_path = tern_find_path(config, "ui\0remember_path\0", TVAL_PTR).ptrval;
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
65 if (!remember_path || !strcmp("on", remember_path)) {
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
66 char const *parts[] = {get_userdata_dir(), PATH_SEP, "sticky_path"};
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
67 char *pathfname = alloc_concat_m(3, parts);
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
68 FILE *f = fopen(pathfname, "rb");
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
69 if (f) {
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
70 long pathsize = file_size(f);
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
71 if (pathsize > 0) {
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
72 *dst = malloc(pathsize + 1);
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
73 if (fread(*dst, 1, pathsize, f) != pathsize) {
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
74 warning("Error restoring saved file browser path");
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
75 free(*dst);
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
76 *dst = NULL;
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
77 } else {
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
78 (*dst)[pathsize] = 0;
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
79 }
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
80 }
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
81 fclose(f);
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
82 }
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
83 free(pathfname);
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
84 if (!current_path) {
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
85 atexit(persist_path);
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
86 current_path = dst;
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
87 }
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
88 }
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
89 if (!*dst) {
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
90 *dst = tern_find_path(config, "ui\0initial_path\0", TVAL_PTR).ptrval;
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
91 }
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
92 if (!*dst){
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
93 #ifdef __ANDROID__
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
94 *dst = get_external_storage_path();
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
95 #else
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
96 *dst = "$HOME";
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
97 #endif
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
98 }
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
99 tern_node *vars = tern_insert_ptr(NULL, "HOME", get_home_dir());
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
100 vars = tern_insert_ptr(vars, "EXEDIR", get_exe_dir());
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
101 *dst = replace_vars(*dst, vars, 1);
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
102 tern_free(vars);
152a60c6787e Moved initial path logic out of menu so it can be shared with new UI
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
103 }
1481
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
104
1489
637fbc3b5063 Added code to persist config back to a file
Michael Pavone <pavone@retrodev.com>
parents: 1481
diff changeset
105 char *path_append(const char *base, const char *suffix)
1481
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
106 {
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
107 if (!strcmp(suffix, "..")) {
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
108 #ifdef _WIN32
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
109 //handle transition from root of a drive to virtual root
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
110 if (base[1] == ':' && !base[2]) {
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
111 return strdup(PATH_SEP)
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
112 }
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
113 #endif
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
114 size_t len = strlen(base);
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
115 while (len > 0) {
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
116 --len;
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
117 if (is_path_sep(base[len])) {
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
118 if (!len) {
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
119 //special handling for /
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
120 len++;
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
121 }
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
122 char *ret = malloc(len+1);
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
123 memcpy(ret, base, len);
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
124 ret[len] = 0;
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
125 return ret;
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
126 }
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
127 }
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
128 return strdup(PATH_SEP);
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
129 } else {
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
130 #ifdef _WIN32
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
131 if (base[0] == PATH_SEP[0] && !base[1]) {
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
132 //handle transition from virtual root to root of a drive
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
133 return strdup(suffix);
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
134 }
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
135 #endif
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
136 if (is_path_sep(base[strlen(base) - 1])) {
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
137 return alloc_concat(base, suffix);
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
138 } else {
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
139 char const *pieces[] = {base, PATH_SEP, suffix};
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
140 return alloc_concat_m(3, pieces);
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
141 }
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
142 }
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
143 }