diff options
| author | Jens Arnold <amiconn@rockbox.org> | 2005-09-02 01:15:35 +0000 |
|---|---|---|
| committer | Jens Arnold <amiconn@rockbox.org> | 2005-09-02 01:15:35 +0000 |
| commit | 58e9412bff9947e4514c0d55152bfad91049a60c (patch) | |
| tree | dc4cc3d7812388805c07c08d4cd9271eecab938e /apps/settings.c | |
| parent | c7240cf844d7c2a28031aa5ec984f0e007de242d (diff) | |
| download | rockbox-58e9412bff9947e4514c0d55152bfad91049a60c.zip rockbox-58e9412bff9947e4514c0d55152bfad91049a60c.tar.gz rockbox-58e9412bff9947e4514c0d55152bfad91049a60c.tar.bz2 rockbox-58e9412bff9947e4514c0d55152bfad91049a60c.tar.xz | |
Added universal functions for creation of numbered filenames and date+time filenames (units with RTC only). Some size optimisations within code using these new functions. Everything should behave as before, except config saving will always find the highest file number + 1 even if the sequence is non-contiguous.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7449 a1c6a512-1295-4272-9138-f99709370657
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 6649ce3..00ca6c8 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) bool settings_save_config(void) { - bool done = false; - int fd, i; + int fd; char filename[MAX_PATH]; - - /* find unused filename */ - for (i=0; ; i++) { - snprintf(filename, sizeof filename, ROCKBOX_DIR "/config%02d.cfg", i); - fd = open(filename, O_RDONLY); - if (fd < 0) - break; - close(fd); - } + + create_numbered_filename(filename, ROCKBOX_DIR, "config", ".cfg", 2); /* allow user to modify filename */ - while (!done) { + while (true) { if (!kbd_input(filename, sizeof filename)) { fd = creat(filename,0); if (fd < 0) { lcd_clear_display(); - lcd_puts(0,0,str(LANG_FAILED)); - lcd_update(); - sleep(HZ); + splash(HZ, true, str(LANG_FAILED)); } else - done = true; + break; + } + else { + lcd_clear_display(); + splash(HZ, true, str(LANG_RESET_DONE_CANCEL)); + return false; } - else - break; - } - - /* abort if file couldn't be created */ - if (!done) { - lcd_clear_display(); - lcd_puts(0,0,str(LANG_RESET_DONE_CANCEL)); - lcd_update(); - sleep(HZ); - return false; } - fdprintf(fd, "# .cfg file created by rockbox %s - ", appsversion); - fdprintf(fd, "http://www.rockbox.org\r\n#\r\n"); - fdprintf(fd, "#\r\n# wps / language / font \r\n#\r\n"); + fdprintf(fd, "# .cfg file created by rockbox %s - " + "http://www.rockbox.org\r\n#\r\n" + "#\r\n# wps / language / font \r\n#\r\n", appsversion); if (global_settings.wps_file[0] != 0) fdprintf(fd, "wps: %s/%s.wps\r\n", ROCKBOX_DIR, - global_settings.wps_file); + global_settings.wps_file); if (global_settings.lang_file[0] != 0) - fdprintf(fd, "lang: %s/%s.lng\r\n", ROCKBOX_DIR LANG_DIR, - global_settings.lang_file); + fdprintf(fd, "lang: %s/%s.lng\r\n", ROCKBOX_DIR LANG_DIR, + global_settings.lang_file); #ifdef HAVE_LCD_BITMAP if (global_settings.font_file[0] != 0) fdprintf(fd, "font: %s/%s.fnt\r\n", ROCKBOX_DIR FONT_DIR, - global_settings.font_file); + global_settings.font_file); #endif /* here's the action: write values to file, specified via table */ @@ -1279,10 +1263,8 @@ bool settings_save_config(void) close(fd); lcd_clear_display(); - lcd_puts(0,0,str(LANG_SETTINGS_SAVED1)); - lcd_puts(0,1,str(LANG_SETTINGS_SAVED2)); - lcd_update(); - sleep(HZ); + splash(HZ, true, "%s %s", str(LANG_SETTINGS_SAVED1), + str(LANG_SETTINGS_SAVED2)); return true; } |