summaryrefslogtreecommitdiff
path: root/riscos/save.c
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2004-06-06 19:39:17 +0000
committerJames Bursa <james@netsurf-browser.org>2004-06-06 19:39:17 +0000
commit6879c02a332824ff63ce0b56de36996d2f0d48cf (patch)
treec53d0d737ca9063d78a0c08d52081348a4c74538 /riscos/save.c
parent9dde0f406f4369c9cd327acdb65f25bf7b85d276 (diff)
downloadnetsurf-6879c02a332824ff63ce0b56de36996d2f0d48cf.tar.gz
netsurf-6879c02a332824ff63ce0b56de36996d2f0d48cf.tar.bz2
[project @ 2004-06-06 19:39:17 by bursa]
Add and improve error handling of save_complete. Save HTML as UTF-8 to prevent encoding issues. svn path=/import/netsurf/; revision=931
Diffstat (limited to 'riscos/save.c')
-rw-r--r--riscos/save.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/riscos/save.c b/riscos/save.c
index 22278bf9c..ba636435d 100644
--- a/riscos/save.c
+++ b/riscos/save.c
@@ -35,7 +35,7 @@ extern struct content *save_content;
typedef enum { LINK_ACORN, LINK_ANT, LINK_TEXT } link_format;
-static void ro_gui_save_complete(struct content *c, char *path);
+static bool ro_gui_save_complete(struct content *c, char *path);
static void ro_gui_save_object_native(struct content *c, char *path);
static bool ro_gui_save_link(struct content *c, link_format format, char *path);
@@ -166,7 +166,8 @@ void ro_gui_save_datasave_ack(wimp_message *message)
break;
case GUI_SAVE_COMPLETE:
- ro_gui_save_complete(c, path);
+ if (!ro_gui_save_complete(c, path))
+ return;
break;
case GUI_SAVE_DRAW:
@@ -236,13 +237,17 @@ void ro_gui_save_datasave_ack(wimp_message *message)
/**
* Prepare an application directory and save_complete() to it.
+ *
+ * \param c content of type CONTENT_HTML to save
+ * \param path path to save as
+ * \return true on success, false on error and error reported
*/
#define WIDTH 64
#define HEIGHT 64
#define SPRITE_SIZE (16 + 44 + ((WIDTH / 2 + 3) & ~3) * HEIGHT / 2)
-void ro_gui_save_complete(struct content *c, char *path)
+bool ro_gui_save_complete(struct content *c, char *path)
{
char buf[256];
FILE *fp;
@@ -258,7 +263,7 @@ void ro_gui_save_complete(struct content *c, char *path)
LOG(("xosfile_create_dir: 0x%x: %s",
error->errnum, error->errmess));
warn_user("SaveError", error->errmess);
- return;
+ return false;
}
/* Save !Run file */
@@ -267,7 +272,7 @@ void ro_gui_save_complete(struct content *c, char *path)
if (!fp) {
LOG(("fopen(): errno = %i", errno));
warn_user("SaveError", strerror(errno));
- return;
+ return false;
}
fprintf(fp, "Filer_Run <Obey$Dir>.index\n");
fclose(fp);
@@ -276,7 +281,7 @@ void ro_gui_save_complete(struct content *c, char *path)
LOG(("xosfile_set_type: 0x%x: %s",
error->errnum, error->errmess));
warn_user("SaveError", error->errmess);
- return;
+ return false;
}
/* Create !Sprites */
@@ -288,7 +293,7 @@ void ro_gui_save_complete(struct content *c, char *path)
area = thumbnail_initialise(34, 34, os_MODE8BPP90X90);
if (!area) {
warn_user("NoMemory", 0);
- return;
+ return false;
}
sprite_header = (osspriteop_header *)(area + 1);
strncpy(sprite_header->name, appname + 1, 12);
@@ -305,12 +310,14 @@ void ro_gui_save_complete(struct content *c, char *path)
LOG(("xosspriteop_save_sprite_file: 0x%x: %s",
error->errnum, error->errmess));
warn_user("SaveError", error->errmess);
- return;
+ return false;
}
- save_complete(c, path);
+ return save_complete(c, path);
}
+
+
void ro_gui_save_object_native(struct content *c, char *path)
{
os_error *error;