annotate paths.c @ 1680:326d1a601fb9

Fixed crash bug that could occur in a narrow window of time when loading a ROM
author Michael Pavone <pavone@retrodev.com>
date Thu, 17 Jan 2019 10:00:24 -0800
parents ab3b465c052c
children dda7479f3bbb
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 {
1673
ab3b465c052c Fix Windows implentation of get_config_dir() so config file gets saved to the right place. Fix location for sticky_path file on all platforms
Michael Pavone <pavone@retrodev.com>
parents: 1524
diff changeset
10 char *pathfname = alloc_concat(get_userdata_dir(), PATH_SEP "blastem" PATH_SEP "sticky_path");
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
11 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
12 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
13 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
14 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
15 }
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 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
17 } 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
18 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
19
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 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
22 }
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 #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
25 #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
26 #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
27 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
28 {
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 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
30 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
31 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
32 }
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 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
34 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
35 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
36 }
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 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
39 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
40 (*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
41 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
42 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
43 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
44 }
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 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
47 "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
48 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
49
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 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
51 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
52 (*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
53
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 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
55 (*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
56 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
57 }
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 #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
59
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 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
61 {
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 *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
63 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
64 if (!remember_path || !strcmp("on", remember_path)) {
1673
ab3b465c052c Fix Windows implentation of get_config_dir() so config file gets saved to the right place. Fix location for sticky_path file on all platforms
Michael Pavone <pavone@retrodev.com>
parents: 1524
diff changeset
65 char *pathfname = alloc_concat(get_userdata_dir(), PATH_SEP "blastem" PATH_SEP "sticky_path");
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
66 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
67 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
68 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
69 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
70 *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
71 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
72 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
73 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
74 *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
75 } 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
76 (*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
77 }
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 }
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 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
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 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
82 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
83 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
84 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
85 }
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 }
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 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
88 *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
89 }
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 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
91 #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
92 *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
93 #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
94 *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
95 #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
96 }
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 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
98 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
99 *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
100 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
101 }
1481
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
102
1489
637fbc3b5063 Added code to persist config back to a file
Michael Pavone <pavone@retrodev.com>
parents: 1481
diff changeset
103 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
104 {
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
105 if (!strcmp(suffix, "..")) {
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
106 #ifdef _WIN32
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
107 //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
108 if (base[1] == ':' && !base[2]) {
1524
b96f9fae757f Fix Windows build, added Windows default_font_path implementation
Michael Pavone <pavone@retrodev.com>
parents: 1489
diff changeset
109 return strdup(PATH_SEP);
1481
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
110 }
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
111 #endif
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
112 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
113 while (len > 0) {
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
114 --len;
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
115 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
116 if (!len) {
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
117 //special handling for /
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
118 len++;
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
119 }
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
120 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
121 memcpy(ret, base, len);
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
122 ret[len] = 0;
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
123 return ret;
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
124 }
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
125 }
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
126 return strdup(PATH_SEP);
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
127 } else {
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
128 #ifdef _WIN32
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
129 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
130 //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
131 return strdup(suffix);
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
132 }
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
133 #endif
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
134 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
135 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
136 } else {
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
137 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
138 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
139 }
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
140 }
77a401044935 Fix directory navigation in ROM file chooser in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents: 1473
diff changeset
141 }