1
0
Fork 0
forked from len0rd/rockbox

check separately if the preferences and the bookmark need to be saved

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15701 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Marcoen Hirschberg 2007-11-19 20:51:42 +00:00
parent 77af93b2cd
commit 2b30bf9eac

View file

@ -285,7 +285,10 @@ struct preferences {
int autoscroll_speed; int autoscroll_speed;
} prefs; };
struct preferences prefs;
struct preferences old_prefs;
static unsigned char buffer[BUFFER_SIZE + 1]; static unsigned char buffer[BUFFER_SIZE + 1];
static unsigned char line_break[] = {0,0x20,9,0xB,0xC,'-'}; static unsigned char line_break[] = {0,0x20,9,0xB,0xC,'-'};
@ -1093,6 +1096,8 @@ static void viewer_load_settings(void) /* same name as global, but not the same
rb->close(settings_fd); rb->close(settings_fd);
} }
memcpy(&old_prefs, &prefs, sizeof(struct preferences));
data = (struct bookmark_file_data*)buffer; /* grab the text buffer */ data = (struct bookmark_file_data*)buffer; /* grab the text buffer */
data->bookmarked_files_count = 0; data->bookmarked_files_count = 0;
@ -1174,16 +1179,23 @@ static void viewer_save_settings(void)/* same name as global, but not the same f
{ {
int settings_fd; int settings_fd;
/* don't save if the position didn't change */ /* save the viewer settings if they have been changed */
if (file_pos + screen_top_ptr - buffer == start_position) if (rb->memcmp(&prefs, &old_prefs, sizeof(struct preferences)))
return; {
settings_fd = rb->creat(SETTINGS_FILE); /* create the settings file */ settings_fd = rb->creat(SETTINGS_FILE); /* create the settings file */
if (settings_fd >= 0 )
{
rb->write (settings_fd, &prefs, sizeof(struct preferences)); rb->write (settings_fd, &prefs, sizeof(struct preferences));
rb->close(settings_fd); rb->close(settings_fd);
}
}
/* save the bookmark if the position has changed */
if (file_pos + screen_top_ptr - buffer != start_position)
{
settings_fd = rb->open(BOOKMARKS_FILE, O_WRONLY|O_CREAT); settings_fd = rb->open(BOOKMARKS_FILE, O_WRONLY|O_CREAT);
if (settings_fd >= 0 ) if (settings_fd >= 0 )
{ {
struct bookmarked_file_info b; struct bookmarked_file_info b;
@ -1196,6 +1208,7 @@ static void viewer_save_settings(void)/* same name as global, but not the same f
rb->close(settings_fd); rb->close(settings_fd);
} }
} }
}
static void viewer_exit(void *parameter) static void viewer_exit(void *parameter)
{ {