From d860d93de23a7fb27571de2b0ccb8bee5dd1abc8 Mon Sep 17 00:00:00 2001 From: James Bursa Date: Sun, 15 Jun 2008 00:27:22 +0000 Subject: Check file exists in bitmap_create_file(). Fixes empty local history when Scrap is wiped. svn path=/trunk/netsurf/; revision=4335 --- riscos/bitmap.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/riscos/bitmap.c b/riscos/bitmap.c index 4d8423cdb..613b93c8f 100644 --- a/riscos/bitmap.c +++ b/riscos/bitmap.c @@ -224,9 +224,26 @@ struct bitmap *bitmap_create(int width, int height, unsigned int state) struct bitmap *bitmap_create_file(char *file) { struct bitmap *bitmap; + char *r; + fileswitch_object_type obj_type; + os_error *error; + if (file[0] == '\0') return NULL; + /* check the file exists */ + sprintf(bitmap_unixname, "%s/%s", TEMP_FILENAME_PREFIX, file); + r = __riscosify(bitmap_unixname, 0, __RISCOSIFY_NO_SUFFIX, + bitmap_filename, 256, 0); + if (r == 0) { + LOG(("__riscosify failed")); + return NULL; + } + error = xosfile_read_stamped_no_path(bitmap_filename, + &obj_type, 0, 0, 0, 0, 0); + if ((error) || (obj_type != fileswitch_IS_FILE)) + return NULL; + if (!filename_claim(file)) return NULL; bitmap = calloc(1, sizeof(struct bitmap)); -- cgit v1.2.3