From decb20da5216b4992c0b783b9a11b5811a8950fb Mon Sep 17 00:00:00 2001 From: James Bursa Date: Thu, 5 Jul 2007 04:29:09 +0000 Subject: Add URL file (with the original URL) and Inventory file (listing URLs of objects) to Full Saves. svn path=/trunk/netsurf/; revision=3383 --- riscos/save.c | 7 ++++++- riscos/save_complete.c | 46 ++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 5 deletions(-) (limited to 'riscos') diff --git a/riscos/save.c b/riscos/save.c index d24231ff8..dab5562ae 100644 --- a/riscos/save.c +++ b/riscos/save.c @@ -2,7 +2,7 @@ * This file is part of NetSurf, http://netsurf-browser.org/ * Licensed under the GNU General Public License, * http://www.opensource.org/licenses/gpl-license - * Copyright 2004 James Bursa + * Copyright 2004-2007 James Bursa * Copyright 2005 Adrian Lees */ @@ -799,6 +799,11 @@ bool ro_gui_save_complete(struct content *c, char *path) /* restore sprite name in case the save fails and we need to try again */ memcpy(sprite->name, name, 12); + /* save URL file with original URL */ + snprintf(buf, sizeof buf, "%s.URL", path); + if (!ro_gui_save_link(c, LINK_ANT, buf)) + return false; + return save_complete(c, path); } diff --git a/riscos/save_complete.c b/riscos/save_complete.c index 9a8c103a4..0769e549c 100644 --- a/riscos/save_complete.c +++ b/riscos/save_complete.c @@ -3,7 +3,7 @@ * Licensed under the GNU General Public License, * http://www.opensource.org/licenses/gpl-license * Copyright 2004 John M Bell - * Copyright 2004 James Bursa + * Copyright 2004-2007 James Bursa */ /** \file @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -55,6 +56,7 @@ static bool save_complete_list_add(struct content *content); static struct content * save_complete_list_find(const char *url); static bool save_complete_list_check(struct content *content); static void save_complete_list_dump(void); +static bool save_complete_inventory(const char *path); /** * Save an HTML page with all dependencies. @@ -70,6 +72,9 @@ bool save_complete(struct content *c, const char *path) result = save_complete_html(c, path, true); + if (result) + result = save_complete_inventory(path); + /* free save_complete_list */ while (save_complete_list) { struct save_complete_entry *next = save_complete_list->next; @@ -114,9 +119,11 @@ bool save_complete_html(struct content *c, const char *path, bool index) if (save_complete_list_check(css)) continue; - if (!save_complete_list_add(css)) { - warn_user("NoMemory", 0); - return false; + if (i != STYLESHEET_STYLE) { + if (!save_complete_list_add(css)) { + warn_user("NoMemory", 0); + return false; + } } if (!save_imported_sheets(css, path)) @@ -721,4 +728,35 @@ void save_complete_list_dump(void) entry->content->url); } + +/** + * Create the inventory file listing original URLs. + */ + +bool save_complete_inventory(const char *path) +{ + char spath[256]; + FILE *fp; + + snprintf(spath, sizeof spath, "%s.Inventory", path); + + fp = fopen(spath, "w"); + if (!fp) { + LOG(("fopen(): errno = %i", errno)); + warn_user("SaveError", strerror(errno)); + return false; + } + + struct save_complete_entry *entry; + for (entry = save_complete_list; entry; entry = entry->next) + fprintf(fp, "%x %s\n", + (unsigned int) entry->content, + entry->content->url); + + fclose(fp); + + return true; +} + + #endif -- cgit v1.2.3