From a2465c779fed2fb5eeecd62e692d4bd113a8908f Mon Sep 17 00:00:00 2001 From: Richard Wilson Date: Fri, 21 Apr 2006 23:49:52 +0000 Subject: Remove RISC OS dependencies from filename code. svn path=/trunk/netsurf/; revision=2540 --- content/urldb.c | 7 +++++++ makefile | 4 ++-- riscos/bitmap.c | 29 ++++++++++++++++++++++------- riscos/configure/con_cache.c | 7 +++++-- riscos/gui.c | 31 +++++++++++++++++++------------ 5 files changed, 55 insertions(+), 23 deletions(-) diff --git a/content/urldb.c b/content/urldb.c index a803f5727..e9bbb9012 100644 --- a/content/urldb.c +++ b/content/urldb.c @@ -425,6 +425,13 @@ void urldb_load(const char *filename) /* ensure filename is 'XX.XX.XX.XX' */ if ((s[2] == '.') && (s[5] == '.') && (s[8] == '.')) { + s[2] = '/'; + s[5] = '/'; + s[8] = '/'; + s[11] = '\0'; + p->thumb = bitmap_create_file(s); + } else if ((s[2] == '/') && (s[5] == '/') && + (s[8] == '/')) { s[11] = '\0'; p->thumb = bitmap_create_file(s); } diff --git a/makefile b/makefile index 42b9a70ce..217f9a2d0 100644 --- a/makefile +++ b/makefile @@ -22,7 +22,7 @@ OBJECTS_COMMON += css.o css_enum.o parser.o ruleset.o scanner.o # css/ OBJECTS_COMMON += box.o box_construct.o box_normalise.o form.o \ html.o html_redraw.o imagemap.o layout.o list.o \ table.o textplain.o # render/ -OBJECTS_COMMON += messages.o talloc.o url.o utf8.o \ +OBJECTS_COMMON += filename.o messages.o talloc.o url.o utf8.o \ utils.o # utils/ OBJECTS_COMMON += options.o tree.o # desktop/ @@ -34,7 +34,7 @@ OBJECTS_RISCOS += browser.o history_core.o netsurf.o selection.o \ textinput.o version.o # desktop/ OBJECTS_RISCOS += 401login.o artworks.o assert.o awrender.o bitmap.o \ buffer.o configure.o debugwin.o \ - dialog.o download.o draw.o filename.o filetype.o font.o \ + dialog.o download.o draw.o filetype.o font.o \ global_history.o gui.o help.o history.o hotlist.o image.o \ menus.o message.o mouseactions.o palettes.o plotters.o plugin.o print.o \ query.o save.o save_complete.o save_draw.o save_text.o \ diff --git a/riscos/bitmap.c b/riscos/bitmap.c index 706d3bd62..5ab2f20e5 100644 --- a/riscos/bitmap.c +++ b/riscos/bitmap.c @@ -17,17 +17,18 @@ #include #include #include +#include #include "oslib/osfile.h" #include "oslib/osspriteop.h" #include "netsurf/content/content.h" #include "netsurf/image/bitmap.h" #include "netsurf/riscos/bitmap.h" -#include "netsurf/riscos/filename.h" #include "netsurf/riscos/image.h" #include "netsurf/riscos/options.h" #include "netsurf/riscos/palettes.h" #include "netsurf/riscos/sprite.h" #include "netsurf/riscos/tinct.h" +#include "netsurf/utils/filename.h" #include "netsurf/utils/log.h" #include "netsurf/utils/utils.h" @@ -82,6 +83,7 @@ struct bitmap_compressed_header { unsigned int input_size; }; +char bitmap_unixname[256]; char bitmap_filename[256]; @@ -209,7 +211,7 @@ struct bitmap *bitmap_create_file(char *file) if (file[0] == '\0') return NULL; - if (!ro_filename_claim(file)) + if (!filename_claim(file)) return NULL; bitmap = calloc(1, sizeof(struct bitmap)); if (!bitmap) @@ -806,13 +808,20 @@ void bitmap_load_file(struct bitmap *bitmap) int len; fileswitch_object_type obj_type; os_error *error; + char *r; struct bitmap_compressed_header *bitmap_compressed; osspriteop_header *bitmap_direct; assert(bitmap->filename); - sprintf(bitmap_filename, "%s.%s", CACHE_FILENAME_PREFIX, + sprintf(bitmap_unixname, "%s/%s", TEMP_FILENAME_PREFIX, bitmap->filename); + r = __riscosify(bitmap_unixname, 0, __RISCOSIFY_NO_SUFFIX, + bitmap_filename, 256, 0); + if (r == 0) { + LOG(("__riscosify failed")); + return; + } error = xosfile_read_stamped_no_path(bitmap_filename, &obj_type, 0, 0, &len, 0, 0); if ((error) || (obj_type != fileswitch_IS_FILE)) @@ -879,7 +888,7 @@ void bitmap_load_file(struct bitmap *bitmap) void bitmap_save_file(struct bitmap *bitmap) { unsigned int area_size; - char *filename; + char *filename, *r; os_error *error; struct bitmap_compressed_header *header; @@ -897,10 +906,16 @@ void bitmap_save_file(struct bitmap *bitmap) } /* dump the data (compressed or otherwise) to disk */ - filename = ro_filename_request(); + filename = filename_request(); strcpy(bitmap->filename, filename); - sprintf(bitmap_filename, "%s.%s", CACHE_FILENAME_PREFIX, + sprintf(bitmap_unixname, "%s/%s", TEMP_FILENAME_PREFIX, bitmap->filename); + r = __riscosify(bitmap_unixname, 0, __RISCOSIFY_NO_SUFFIX, + bitmap_filename, 256, 0); + if (r == 0) { + LOG(("__riscosify failed")); + return; + } if (bitmap->compressed) { header = (struct bitmap_compressed_header *)bitmap->compressed; area_size = header->input_size + @@ -940,7 +955,7 @@ void bitmap_save_file(struct bitmap *bitmap) void bitmap_delete_file(struct bitmap *bitmap) { assert(bitmap->filename[0]); - ro_filename_release(bitmap->filename); + filename_release(bitmap->filename); bitmap->filename[0] = 0; } diff --git a/riscos/configure/con_cache.c b/riscos/configure/con_cache.c index 29dbd38de..a21b54fbf 100644 --- a/riscos/configure/con_cache.c +++ b/riscos/configure/con_cache.c @@ -5,15 +5,16 @@ * Copyright 2005 Richard Wilson */ +#include "oslib/hourglass.h" #include "netsurf/desktop/options.h" #include "netsurf/riscos/dialog.h" -#include "netsurf/riscos/filename.h" #include "netsurf/riscos/gui.h" #include "netsurf/riscos/options.h" #include "netsurf/riscos/wimp.h" #include "netsurf/riscos/wimp_event.h" #include "netsurf/riscos/configure.h" #include "netsurf/riscos/configure/configure.h" +#include "netsurf/utils/filename.h" #include "netsurf/utils/messages.h" #include "netsurf/utils/utils.h" @@ -63,7 +64,9 @@ bool ro_gui_options_cache_click(wimp_pointer *pointer) { 28, 0); return true; case CACHE_MAINTAIN_BUTTON: - ro_filename_flush(); + xhourglass_on(); + filename_flush(); + xhourglass_off(); return true; } return false; diff --git a/riscos/gui.c b/riscos/gui.c index 512b7bf43..619a27548 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -50,7 +50,6 @@ #include "netsurf/riscos/bitmap.h" #include "netsurf/riscos/buffer.h" #include "netsurf/riscos/dialog.h" -#include "netsurf/riscos/filename.h" #include "netsurf/riscos/global_history.h" #include "netsurf/riscos/gui.h" #include "netsurf/riscos/help.h" @@ -78,6 +77,7 @@ #include "netsurf/riscos/url_complete.h" #include "netsurf/riscos/wimp.h" #include "netsurf/riscos/wimp_event.h" +#include "netsurf/utils/filename.h" #include "netsurf/utils/log.h" #include "netsurf/utils/messages.h" #include "netsurf/utils/url.h" @@ -307,7 +307,7 @@ void gui_init(int argc, char** argv) prev_sigs.sigterm == SIG_ERR) die("Failed registering signal handlers"); - ro_filename_initialise(); + filename_initialise(); #ifdef WITH_SAVE_COMPLETE save_complete_init(); @@ -1300,9 +1300,9 @@ void ro_gui_keypress(wimp_key *key) */ void ro_gui_user_message(wimp_event_no event, wimp_message *message) { - /* attempt automatic routing */ - if (ro_message_handle_message(event, message)) - return; + /* attempt automatic routing */ + if (ro_message_handle_message(event, message)) + return; switch (message->action) { case message_DATA_LOAD: @@ -2139,8 +2139,9 @@ void ro_gui_open_help_page(const char *page) void ro_gui_view_source(struct content *content) { os_error *error; - char *temp_name; - wimp_full_message_data_xfer message; + char full_name[256]; + char *temp_name, *r; + wimp_full_message_data_xfer message; if (!content || !content->source_data) { warn_user("MiscError", "No document source"); @@ -2159,13 +2160,19 @@ void ro_gui_view_source(struct content *content) bother releasing it and simply allow it to be re-used next time NetSurf is started. The memory overhead from doing this is under 1 byte per filename. */ - temp_name = ro_filename_request(); + temp_name = filename_request(); if (!temp_name) { - warn_user("NoMemory", 0); - return; + warn_user("NoMemory", 0); + return; + } + snprintf(full_name, 256, "%s/%s", TEMP_FILENAME_PREFIX, temp_name); + full_name[255] = '\0'; + r = __riscosify(full_name, 0, __RISCOSIFY_NO_SUFFIX, message.file_name, + 212, 0); + if (r == 0) { + LOG(("__riscosify failed")); + return; } - snprintf(message.file_name, 212, "%s.%s", - CACHE_FILENAME_PREFIX, temp_name); message.file_name[211] = '\0'; error = xosfile_save_stamped(message.file_name, ro_content_filetype(content), -- cgit v1.2.3