diff options
author | Michael Stummvoll <michael@stummi.org> | 2010-11-25 12:45:13 +0000 |
---|---|---|
committer | Michael Stummvoll <michael@stummi.org> | 2010-11-25 12:45:13 +0000 |
commit | 7704a3ccd7b1a3d1092bde0a1ec13ba6196b550b (patch) | |
tree | dd39a8d84f0608dfc932a5e344ccf404c3901215 /apps/plugins/rockboy/loader.c | |
parent | 8971b230dcee4140e207d7a36fb769f385cebc82 (diff) | |
download | rockbox-7704a3ccd7b1a3d1092bde0a1ec13ba6196b550b.tar.gz rockbox-7704a3ccd7b1a3d1092bde0a1ec13ba6196b550b.zip |
Added the snapshot patch for rockboy (FS#11757)
Added a simple filesize-check for the options file before loading
to avoid crashes due the changed config
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28664 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/rockboy/loader.c')
-rw-r--r-- | apps/plugins/rockboy/loader.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/apps/plugins/rockboy/loader.c b/apps/plugins/rockboy/loader.c index 8741dabd12..d843ba8a60 100644 --- a/apps/plugins/rockboy/loader.c +++ b/apps/plugins/rockboy/loader.c | |||
@@ -102,6 +102,7 @@ static const unsigned char ramsize_table[5] = | |||
102 | static const char *romfile; | 102 | static const char *romfile; |
103 | static char sramfile[500]; | 103 | static char sramfile[500]; |
104 | static char rtcfile[500]; | 104 | static char rtcfile[500]; |
105 | static char snfile[500]; | ||
105 | static char saveprefix[500]; | 106 | static char saveprefix[500]; |
106 | 107 | ||
107 | static int forcebatt, nobatt; | 108 | static int forcebatt, nobatt; |
@@ -269,6 +270,24 @@ static void rtc_load(void) | |||
269 | close(fd); | 270 | close(fd); |
270 | } | 271 | } |
271 | 272 | ||
273 | void sn_save(void) | ||
274 | { | ||
275 | int fd; | ||
276 | if ((fd = open(snfile, O_WRONLY | O_CREAT, 0666)) < 0) | ||
277 | return; | ||
278 | savestate(fd); | ||
279 | close(fd); | ||
280 | } | ||
281 | |||
282 | void sn_load(void) | ||
283 | { | ||
284 | int fd; | ||
285 | if ((fd = open(snfile, O_RDONLY, 0666)) < 0) | ||
286 | return; | ||
287 | loadstate(fd); | ||
288 | close(fd); | ||
289 | } | ||
290 | |||
272 | void cleanup(void) | 291 | void cleanup(void) |
273 | { | 292 | { |
274 | sram_save(); | 293 | sram_save(); |
@@ -289,6 +308,8 @@ void loader_init(const char *s) | |||
289 | 308 | ||
290 | strcpy(rtcfile, saveprefix); | 309 | strcpy(rtcfile, saveprefix); |
291 | strcat(rtcfile, ".rtc"); | 310 | strcat(rtcfile, ".rtc"); |
311 | strcpy(snfile, saveprefix); | ||
312 | strcat(snfile, ".sn"); | ||
292 | 313 | ||
293 | sram_load(); | 314 | sram_load(); |
294 | rtc_load(); | 315 | rtc_load(); |