summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorMarcoen Hirschberg <marcoen@gmail.com>2007-11-19 20:51:38 +0000
committerMarcoen Hirschberg <marcoen@gmail.com>2007-11-19 20:51:38 +0000
commit77af93b2cd28cd235927fb9210fa9e87f722559b (patch)
tree1e4465d7446605e8e98e97e91629f79882d424fe /apps/plugins
parentb766f11701218b70f86766adcfe670b8732a61a8 (diff)
write a correct bookmark file when the viewer loads so we can safely skip the write on exit
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15700 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/viewer.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/apps/plugins/viewer.c b/apps/plugins/viewer.c
index 75ecd60215..9f22079c5d 100644
--- a/apps/plugins/viewer.c
+++ b/apps/plugins/viewer.c
@@ -1079,6 +1079,7 @@ static void viewer_load_settings(void) /* same name as global, but not the same
{
int settings_fd, i;
struct bookmark_file_data *data;
+ struct bookmarked_file_info this_bookmark;
/* read settings file */
settings_fd=rb->open(SETTINGS_FILE, O_RDONLY);
@@ -1106,7 +1107,10 @@ static void viewer_load_settings(void) /* same name as global, but not the same
rb->read(settings_fd, data->bookmarks,
sizeof(struct bookmarked_file_info) * data->bookmarked_files_count);
rb->close(settings_fd);
- }
+ }
+
+ file_pos = 0;
+ screen_top_ptr = buffer;
/* check if current file is in list */
for (i=0; i < data->bookmarked_files_count; i++)
@@ -1119,6 +1123,12 @@ static void viewer_load_settings(void) /* same name as global, but not the same
}
}
+ this_bookmark.file_position = file_pos;
+ this_bookmark.top_ptr_pos = screen_top_ptr - buffer;
+
+ rb->memset(&this_bookmark.filename[0],0,MAX_PATH);
+ rb->strcpy(this_bookmark.filename,file_name);
+
/* prevent potential slot overflow */
if (i >= data->bookmarked_files_count)
{
@@ -1133,12 +1143,15 @@ static void viewer_load_settings(void) /* same name as global, but not the same
settings_fd = rb->open(BOOKMARKS_FILE, O_WRONLY|O_CREAT);
if (settings_fd >=0 )
{
- /* write count and skip first slot */
+ /* write count */
rb->write (settings_fd, &data->bookmarked_files_count, sizeof(signed int));
- rb->PREFIX(lseek)(settings_fd,sizeof(struct bookmarked_file_info),SEEK_CUR);
- /* shuffle up bookmarks */
+ /* write the current bookmark */
+ rb->write (settings_fd, &this_bookmark, sizeof(struct bookmarked_file_info));
+
+ /* write everything that was before this bookmark */
rb->write (settings_fd, data->bookmarks, sizeof(struct bookmarked_file_info)*i);
+
rb->close(settings_fd);
}