From badad073ec99b49288421e99a701f3a61f1fac55 Mon Sep 17 00:00:00 2001 From: Richard Wilson Date: Thu, 6 Jul 2006 00:07:11 +0000 Subject: Generate directory listings (fix 1397934) svn path=/trunk/netsurf/; revision=2719 --- riscos/filetype.c | 18 +++++++++++++----- riscos/gui.c | 13 ++++++++++--- 2 files changed, 23 insertions(+), 8 deletions(-) (limited to 'riscos') diff --git a/riscos/filetype.c b/riscos/filetype.c index a763e46f8..9a26dad8d 100644 --- a/riscos/filetype.c +++ b/riscos/filetype.c @@ -1,7 +1,7 @@ /* * This file is part of NetSurf, http://netsurf.sourceforge.net/ * Licensed under the GNU General Public License, - * http://www.opensource.org/licenses/gpl-license + * http://www.opensource.org/licenses/gpl-license * Copyright 2004 James Bursa */ @@ -23,8 +23,8 @@ struct type_entry { char mime_type[40]; }; static const struct type_entry type_map[] = { - {0x132, "image/ico"}, - {0x188, "application/x-shockwave-flash"}, + {0x132, "image/ico"}, + {0x188, "application/x-shockwave-flash"}, {0x695, "image/gif"}, {0x69c, "image/x-ms-bmp"}, {0xaff, "image/x-drawfile"}, @@ -51,7 +51,7 @@ static int cmp_type(const void *x, const void *y); * * \param unix_path Unix style path to file on disk * \return Pointer to MIME type string (should not be freed) - invalidated - * on next call to fetch_filetype. + * on next call to fetch_filetype. */ const char *fetch_filetype(const char *unix_path) { @@ -61,6 +61,7 @@ const char *fetch_filetype(const char *unix_path) char *r, *slash; os_error *error; bits file_type, temp; + int objtype; if (!path) { LOG(("Insufficient memory for calloc")); @@ -78,7 +79,8 @@ const char *fetch_filetype(const char *unix_path) } LOG(("riscos path '%s'", path)); - error = xosfile_read_stamped_no_path(path, 0, 0, 0, 0, 0, &file_type); + error = xosfile_read_stamped_no_path(path, &objtype, 0, 0, 0, 0, + &file_type); if (error) { LOG(("xosfile_read_stamped_no_path failed: %s", error->errmess)); @@ -86,6 +88,11 @@ const char *fetch_filetype(const char *unix_path) return "application/riscos"; } + if (objtype == osfile_IS_DIR) { + sprintf(type_buf, "application/x-netsurf-directory"); + return (const char *)type_buf; + } + /* If filetype is text and the file has an extension, try to map the * extension to a filetype via the MimeMap file. */ if (file_type == osfile_TYPE_TEXT) { @@ -157,6 +164,7 @@ char *fetch_mimetype(const char *ro_path) return 0; if (objtype == osfile_IS_DIR) + sprintf(mime, "application/x-netsurf-directory"); return 0; /* directories are pointless */ if ((load >> 20) & 0xFFF) { diff --git a/riscos/gui.c b/riscos/gui.c index 5abddac3d..53fd4ea74 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -2157,6 +2157,8 @@ void ro_gui_view_source(struct content *content) char full_name[256]; char *temp_name, *r; wimp_full_message_data_xfer message; + int objtype; + bool done = false; if (!content || !content->source_data) { warn_user("MiscError", "No document source"); @@ -2166,10 +2168,15 @@ void ro_gui_view_source(struct content *content) /* try to load local files directly. */ temp_name = url_to_path(content->url); if (temp_name) { - snprintf(message.file_name, 212, "%s", temp_name); - message.file_name[211] = '\0'; + error = xosfile_read_no_path(temp_name, &objtype, 0, 0, 0, 0); + if ((!error) && (objtype == osfile_IS_FILE)) { + snprintf(message.file_name, 212, "%s", temp_name); + message.file_name[211] = '\0'; + done = true; + } free(temp_name); - } else { + } + if (!done) { /* We cannot release the requested filename until after it * has finished being used. As we can't easily find out when * this is, we simply don't bother releasing it and simply -- cgit v1.2.3