Mercurial > repos > blastem
comparison 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 | bebc3589dedf |
comparison
equal
deleted
inserted
replaced
2424:767ec72acca7 | 2425:794ba17f0716 |
---|---|
1014 } | 1014 } |
1015 | 1015 |
1016 #else | 1016 #else |
1017 | 1017 |
1018 #ifndef IS_LIB | 1018 #ifndef IS_LIB |
1019 char *read_bundled_file(char *name, uint32_t *sizeret) | 1019 char *bundled_file_path(char *name) |
1020 { | 1020 { |
1021 #ifdef DATA_PATH | 1021 #ifdef DATA_PATH |
1022 char *data_dir = DATA_PATH; | 1022 char *data_dir = DATA_PATH; |
1023 #else | 1023 #else |
1024 char *data_dir = get_exe_dir(); | 1024 char *data_dir = get_exe_dir(); |
1025 if (!data_dir) { | 1025 if (!data_dir) { |
1026 return NULL; | |
1027 } | |
1028 #endif | |
1029 char const *pieces[] = {data_dir, PATH_SEP, name}; | |
1030 return alloc_concat_m(3, pieces); | |
1031 } | |
1032 | |
1033 char *read_bundled_file(char *name, uint32_t *sizeret) | |
1034 { | |
1035 char *path = bundled_file_path(name); | |
1036 if (!path) { | |
1026 if (sizeret) { | 1037 if (sizeret) { |
1027 *sizeret = -1; | 1038 *sizeret = -1; |
1028 } | 1039 } |
1029 return NULL; | 1040 return NULL; |
1030 } | 1041 } |
1031 #endif | |
1032 char const *pieces[] = {data_dir, PATH_SEP, name}; | |
1033 char *path = alloc_concat_m(3, pieces); | |
1034 FILE *f = fopen(path, "rb"); | 1042 FILE *f = fopen(path, "rb"); |
1035 free(path); | 1043 free(path); |
1036 if (!f) { | 1044 if (!f) { |
1037 if (sizeret) { | 1045 if (sizeret) { |
1038 *sizeret = -1; | 1046 *sizeret = -1; |