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
This commit is contained in:
parent
b766f11701
commit
77af93b2cd
1 changed files with 17 additions and 4 deletions
|
@ -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);
|
||||
|
@ -1108,6 +1109,9 @@ static void viewer_load_settings(void) /* same name as global, but not the same
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue