diff options
author | Hardeep Sidhu <dyp@pobox.com> | 2003-08-08 01:50:51 +0000 |
---|---|---|
committer | Hardeep Sidhu <dyp@pobox.com> | 2003-08-08 01:50:51 +0000 |
commit | a9fded1605b19e3853ccc26ae75dbeebede2191f (patch) | |
tree | 42a0768dfdaae7016bf448533b4d0526048bc373 /apps | |
parent | 7f67717b00433b8fc1a7624a491c446d3c021bfe (diff) |
Huw Smith's fix for saving memo function.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3926 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugins/calendar.c | 73 |
1 files changed, 25 insertions, 48 deletions
diff --git a/apps/plugins/calendar.c b/apps/plugins/calendar.c index 233fc096d1..0247870f76 100644 --- a/apps/plugins/calendar.c +++ b/apps/plugins/calendar.c @@ -6,7 +6,7 @@ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ * $Id$ - * (based upon 1.1 by calpefrosch) www.HuwSy.ukhackers.net + * (based upon 1.1 by calpefrosch) updated by www.HuwSy.ukhackers.net * * Copyright (C) 2002 * @@ -307,12 +307,13 @@ static bool save_memo(int changed, bool new_mod, struct shown *shown) int i; char temp[MAX_CHAR_MEMO_LEN + 1]; rb->lseek(fp, 0, SEEK_SET); - if ( (memos[changed].file_pointer_start == 0) && - (memos[changed].file_pointer_end == 0) && (new_mod) ) + for (i = 0; i < memos[changed].file_pointer_start; i++) + { + rb->read(fp, temp, 1); + rb->write(fq,temp,1); + } + if (new_mod) { - rb->close(fp); - rb->close(fq); - fq = rb->open("/.rockbox/.memo",O_RDONLY | O_CREAT | O_APPEND); rb->snprintf(temp, 2, "%02d", memos[changed].day); rb->write(fq,temp,2); rb->snprintf(temp, 2, "%02d", memos[changed].month); @@ -323,51 +324,27 @@ static bool save_memo(int changed, bool new_mod, struct shown *shown) rb->write(fq,temp,1); rb->snprintf(temp, 1, "%01d", memos[changed].type); rb->write(fq,temp,1); - rb->snprintf(temp, rb->strlen(memos[changed].message)+1, "%s\n", - memos[changed].message); - rb->write(fq,temp,rb->strlen(temp)); + rb->snprintf(temp, rb->strlen(memos[changed].message)+1, + "%s\n", memos[changed].message); + rb->write(fq,temp, rb->strlen(temp)); } - else + rb->lseek(fp, memos[changed].file_pointer_end, SEEK_SET); + for (i = memos[changed].file_pointer_end; + i < rb->filesize(fp); i++) { - for (i = 0; i < memos[changed].file_pointer_start; i++) - { - rb->read(fp, temp, 1); - rb->write(fq,temp,1); - } - if (new_mod) - { - rb->snprintf(temp, 2, "%02d", memos[changed].day); - rb->write(fq,temp,2); - rb->snprintf(temp, 2, "%02d", memos[changed].month); - rb->write(fq,temp,2); - rb->snprintf(temp, 4, "%04d", memos[changed].year); - rb->write(fq,temp,4); - rb->snprintf(temp, 1, "%01d", memos[changed].wday); - rb->write(fq,temp,1); - rb->snprintf(temp, 1, "%01d", memos[changed].type); - rb->write(fq,temp,1); - rb->snprintf(temp, rb->strlen(memos[changed].message)+1, - "%s\n", memos[changed].message); - rb->write(fq,temp, rb->strlen(temp)); - } - rb->lseek(fp, memos[changed].file_pointer_end, SEEK_SET); - for (i = memos[changed].file_pointer_end; - i < rb->filesize(fp); i++) - { - rb->read(fp, temp, 1); - rb->write(fq,temp,1); - } - rb->close(fp); - fp = rb->open("/.rockbox/.memo",O_WRONLY | O_CREAT | O_TRUNC); - rb->lseek(fp, 0, SEEK_SET); - rb->lseek(fq, 0, SEEK_SET); - for (i = 0; i < rb->filesize(fq); i++) - { - rb->read(fq, temp, 1); - rb->write(fp,temp,1); - } - rb->close(fp); + rb->read(fp, temp, 1); + rb->write(fq,temp,1); } + rb->close(fp); + fp = rb->open("/.rockbox/.memo",O_WRONLY | O_CREAT | O_TRUNC); + rb->lseek(fp, 0, SEEK_SET); + rb->lseek(fq, 0, SEEK_SET); + for (i = 0; i < rb->filesize(fq); i++) + { + rb->read(fq, temp, 1); + rb->write(fp,temp,1); + } + rb->close(fp); rb->close(fq); rb->remove("/.rockbox/~temp"); load_memo(shown); |