| 1111 | |
| 1112 | void set_default_prefix_locations(const char *programPath); |
| 1113 | boolean |
| 1114 | test_portable_config(const char *executable_path, char *portable_device_path, |
| 1115 | size_t portable_device_path_size) |
| 1116 | { |
| 1117 | int lth = 0; |
| 1118 | const char *sysconf = "sysconf"; |
| 1119 | char tmppath[MAX_PATH]; |
| 1120 | boolean retval = FALSE, |
| 1121 | save_initoptions_noterminate = iflags.initoptions_noterminate; |
| 1122 | |
| 1123 | if (portable_device_path |
| 1124 | && folder_file_exists(executable_path, "sysconf")) { |
| 1125 | /* |
| 1126 | There is a sysconf file (not just sysconf.template) present in |
| 1127 | the exe path, which is not the way NetHack is initially |
| 1128 | distributed, so assume it means that the admin/installer wants to |
| 1129 | override something, perhaps set up for a fully-portable |
| 1130 | configuration that leaves no traces behind elsewhere on this |
| 1131 | computer's hard drive - delve into that... |
| 1132 | */ |
| 1133 | |
| 1134 | *portable_device_path = '\0'; |
| 1135 | lth = sizeof tmppath - strlen(sysconf); |
| 1136 | (void) strncpy(tmppath, executable_path, lth - 1); |
| 1137 | tmppath[lth - 1] = '\0'; |
| 1138 | (void) strcat(tmppath, sysconf); |
| 1139 | |
| 1140 | iflags.initoptions_noterminate = 1; |
| 1141 | /* assure_syscf_file(); */ |
| 1142 | config_error_init(TRUE, tmppath, FALSE); |
| 1143 | /* ... and _must_ parse correctly. */ |
| 1144 | if (read_config_file(tmppath, set_in_sysconf) |
| 1145 | && sysopt.portable_device_paths) |
| 1146 | retval = TRUE; |
| 1147 | (void) config_error_done(); |
| 1148 | iflags.initoptions_noterminate = save_initoptions_noterminate; |
| 1149 | sysopt_release(); /* the real sysconf processing comes later */ |
| 1150 | } |
| 1151 | if (retval) { |
| 1152 | lth = strlen(executable_path); |
| 1153 | if (lth <= (int) portable_device_path_size - 1) |
| 1154 | Strcpy(portable_device_path, executable_path); |
| 1155 | else |
| 1156 | retval = FALSE; |
| 1157 | } |
| 1158 | return retval; |
| 1159 | } |
| 1160 | |
| 1161 | const char * |
| 1162 | get_portable_device(void) |
no test coverage detected