diff options
Diffstat (limited to 'apps/settings.c')
-rw-r--r-- | apps/settings.c | 58 |
1 files changed, 20 insertions, 38 deletions
diff --git a/apps/settings.c b/apps/settings.c index 6649ce3f89..00ca6c82c3 100644 --- a/apps/settings.c +++ b/apps/settings.c | |||
@@ -1215,61 +1215,45 @@ static void save_cfg_table(const struct bit_entry* p_table, int count, int fd) | |||
1215 | 1215 | ||
1216 | bool settings_save_config(void) | 1216 | bool settings_save_config(void) |
1217 | { | 1217 | { |
1218 | bool done = false; | 1218 | int fd; |
1219 | int fd, i; | ||
1220 | char filename[MAX_PATH]; | 1219 | char filename[MAX_PATH]; |
1221 | 1220 | ||
1222 | /* find unused filename */ | 1221 | create_numbered_filename(filename, ROCKBOX_DIR, "config", ".cfg", 2); |
1223 | for (i=0; ; i++) { | ||
1224 | snprintf(filename, sizeof filename, ROCKBOX_DIR "/config%02d.cfg", i); | ||
1225 | fd = open(filename, O_RDONLY); | ||
1226 | if (fd < 0) | ||
1227 | break; | ||
1228 | close(fd); | ||
1229 | } | ||
1230 | 1222 | ||
1231 | /* allow user to modify filename */ | 1223 | /* allow user to modify filename */ |
1232 | while (!done) { | 1224 | while (true) { |
1233 | if (!kbd_input(filename, sizeof filename)) { | 1225 | if (!kbd_input(filename, sizeof filename)) { |
1234 | fd = creat(filename,0); | 1226 | fd = creat(filename,0); |
1235 | if (fd < 0) { | 1227 | if (fd < 0) { |
1236 | lcd_clear_display(); | 1228 | lcd_clear_display(); |
1237 | lcd_puts(0,0,str(LANG_FAILED)); | 1229 | splash(HZ, true, str(LANG_FAILED)); |
1238 | lcd_update(); | ||
1239 | sleep(HZ); | ||
1240 | } | 1230 | } |
1241 | else | 1231 | else |
1242 | done = true; | 1232 | break; |
1233 | } | ||
1234 | else { | ||
1235 | lcd_clear_display(); | ||
1236 | splash(HZ, true, str(LANG_RESET_DONE_CANCEL)); | ||
1237 | return false; | ||
1243 | } | 1238 | } |
1244 | else | ||
1245 | break; | ||
1246 | } | ||
1247 | |||
1248 | /* abort if file couldn't be created */ | ||
1249 | if (!done) { | ||
1250 | lcd_clear_display(); | ||
1251 | lcd_puts(0,0,str(LANG_RESET_DONE_CANCEL)); | ||
1252 | lcd_update(); | ||
1253 | sleep(HZ); | ||
1254 | return false; | ||
1255 | } | 1239 | } |
1256 | 1240 | ||
1257 | fdprintf(fd, "# .cfg file created by rockbox %s - ", appsversion); | 1241 | fdprintf(fd, "# .cfg file created by rockbox %s - " |
1258 | fdprintf(fd, "http://www.rockbox.org\r\n#\r\n"); | 1242 | "http://www.rockbox.org\r\n#\r\n" |
1259 | fdprintf(fd, "#\r\n# wps / language / font \r\n#\r\n"); | 1243 | "#\r\n# wps / language / font \r\n#\r\n", appsversion); |
1260 | 1244 | ||
1261 | if (global_settings.wps_file[0] != 0) | 1245 | if (global_settings.wps_file[0] != 0) |
1262 | fdprintf(fd, "wps: %s/%s.wps\r\n", ROCKBOX_DIR, | 1246 | fdprintf(fd, "wps: %s/%s.wps\r\n", ROCKBOX_DIR, |
1263 | global_settings.wps_file); | 1247 | global_settings.wps_file); |
1264 | 1248 | ||
1265 | if (global_settings.lang_file[0] != 0) | 1249 | if (global_settings.lang_file[0] != 0) |
1266 | fdprintf(fd, "lang: %s/%s.lng\r\n", ROCKBOX_DIR LANG_DIR, | 1250 | fdprintf(fd, "lang: %s/%s.lng\r\n", ROCKBOX_DIR LANG_DIR, |
1267 | global_settings.lang_file); | 1251 | global_settings.lang_file); |
1268 | 1252 | ||
1269 | #ifdef HAVE_LCD_BITMAP | 1253 | #ifdef HAVE_LCD_BITMAP |
1270 | if (global_settings.font_file[0] != 0) | 1254 | if (global_settings.font_file[0] != 0) |
1271 | fdprintf(fd, "font: %s/%s.fnt\r\n", ROCKBOX_DIR FONT_DIR, | 1255 | fdprintf(fd, "font: %s/%s.fnt\r\n", ROCKBOX_DIR FONT_DIR, |
1272 | global_settings.font_file); | 1256 | global_settings.font_file); |
1273 | #endif | 1257 | #endif |
1274 | 1258 | ||
1275 | /* here's the action: write values to file, specified via table */ | 1259 | /* here's the action: write values to file, specified via table */ |
@@ -1279,10 +1263,8 @@ bool settings_save_config(void) | |||
1279 | close(fd); | 1263 | close(fd); |
1280 | 1264 | ||
1281 | lcd_clear_display(); | 1265 | lcd_clear_display(); |
1282 | lcd_puts(0,0,str(LANG_SETTINGS_SAVED1)); | 1266 | splash(HZ, true, "%s %s", str(LANG_SETTINGS_SAVED1), |
1283 | lcd_puts(0,1,str(LANG_SETTINGS_SAVED2)); | 1267 | str(LANG_SETTINGS_SAVED2)); |
1284 | lcd_update(); | ||
1285 | sleep(HZ); | ||
1286 | return true; | 1268 | return true; |
1287 | } | 1269 | } |
1288 | 1270 | ||