diff util.c @ 2425:794ba17f0716

Make termhelper work when current working directory is not the one that contains blastem
author Michael Pavone <pavone@retrodev.com>
date Wed, 24 Jan 2024 20:18:17 -0800
parents 1a3991ada927
children
line wrap: on
line diff
--- a/util.c	Wed Jan 24 18:51:44 2024 -0800
+++ b/util.c	Wed Jan 24 20:18:17 2024 -0800
@@ -1016,21 +1016,29 @@
 #else
 
 #ifndef IS_LIB
-char *read_bundled_file(char *name, uint32_t *sizeret)
+char *bundled_file_path(char *name)
 {
 #ifdef DATA_PATH
 	char *data_dir = DATA_PATH;
 #else
 	char *data_dir = get_exe_dir();
 	if (!data_dir) {
+		return NULL;
+	}
+#endif
+	char const *pieces[] = {data_dir, PATH_SEP, name};
+	return alloc_concat_m(3, pieces);
+}
+
+char *read_bundled_file(char *name, uint32_t *sizeret)
+{
+	char *path = bundled_file_path(name);
+	if (!path) {
 		if (sizeret) {
 			*sizeret = -1;
 		}
 		return NULL;
 	}
-#endif
-	char const *pieces[] = {data_dir, PATH_SEP, name};
-	char *path = alloc_concat_m(3, pieces);
 	FILE *f = fopen(path, "rb");
 	free(path);
 	if (!f) {