From e5b4913d19b40176cbaebe9453febadcab87b76c Mon Sep 17 00:00:00 2001 From: Michiel Van Der Kolk Date: Sat, 5 Mar 2005 22:50:41 +0000 Subject: Minor bug when writing files; files weren't truncated to 0, so when writing a file smaller than the previous one, it adds garbage to the end. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6147 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/rockboy/loader.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'apps/plugins/rockboy/loader.c') diff --git a/apps/plugins/rockboy/loader.c b/apps/plugins/rockboy/loader.c index ad7c309bd8..dc89cddf8b 100644 --- a/apps/plugins/rockboy/loader.c +++ b/apps/plugins/rockboy/loader.c @@ -218,7 +218,7 @@ int sram_save(void) /* If we crash before we ever loaded sram, DO NOT SAVE! */ if (!mbc.batt || !sramfile || !ram.loaded || !mbc.ramsize) return -1; - fd = open(sramfile, O_WRONLY|O_CREAT); + fd = open(sramfile, O_WRONLY|O_CREAT|O_TRUNC); // snprintf(meow,499,"Opening %s %d",sramfile,fd); // rb->splash(HZ*2, true, meow); if (fd<0) return -1; @@ -240,7 +240,7 @@ void state_save(int n) if (n < 0) n = 0; snprintf(name, 499,"%s.%03d", saveprefix, n); - if ((fd = open(name, O_WRONLY|O_CREAT)>=0)) + if ((fd = open(name, O_WRONLY|O_CREAT|O_TRUNC)>=0)) { savestate(fd); close(fd); @@ -272,7 +272,7 @@ void rtc_save(void) { int fd; if (!rtc.batt) return; - if ((fd = open(rtcfile, O_WRONLY|O_CREAT))<0) return; + if ((fd = open(rtcfile, O_WRONLY|O_CREAT|O_TRUNC))<0) return; rtc_save_internal(fd); close(fd); } -- cgit v1.2.3