diff options
author | John-Mark Bell <jmb@netsurf-browser.org> | 2012-11-03 23:19:28 +0000 |
---|---|---|
committer | John-Mark Bell <jmb@netsurf-browser.org> | 2012-11-03 23:19:45 +0000 |
commit | f824ab8af4d3d2e34bd59b860b9c6d5568c3bb44 (patch) | |
tree | 70f5f8d5a3ec2f952b18f59a6ed632f207f8a50f /riscos/save.c | |
parent | 3f1b68384562fe294a1a263214a3fd26ea869bc9 (diff) | |
download | netsurf-f824ab8af4d3d2e34bd59b860b9c6d5568c3bb44.tar.gz netsurf-f824ab8af4d3d2e34bd59b860b9c6d5568c3bb44.tar.bz2 |
Port save complete to libdom.
Diffstat (limited to 'riscos/save.c')
-rw-r--r-- | riscos/save.c | 67 |
1 files changed, 6 insertions, 61 deletions
diff --git a/riscos/save.c b/riscos/save.c index 064b252d4..f61fd012b 100644 --- a/riscos/save.c +++ b/riscos/save.c @@ -975,71 +975,16 @@ void ro_gui_save_done(void) gui_save_content = 0; } -/** -* conducts the filesystem save appropriate to the gui -* \param path save path -* \param filename name of file to save -* \param len data length -* \param sourcedata pointer to data to save, NULL when all data in c -* \param type content type -* \return true for success -*/ - -bool save_complete_gui_save(const char *path, const char *filename, size_t len, - const char *sourcedata, lwc_string *mime_type) -{ - char *fullpath; - os_error *error; - int namelen = strlen(path) + strlen(filename) + 2; - int rotype; - fullpath = malloc(namelen); - if (fullpath == NULL) { - warn_user("NoMemory", 0); - return false; - } - snprintf(fullpath, namelen, "%s.%s", path, filename); - rotype = ro_content_filetype_from_mime_type(mime_type); - error = xosfile_save_stamped(fullpath, rotype, (byte *) sourcedata, - (byte *) sourcedata + len); - free(fullpath); - if (error) { - LOG(("xosfile_save_stamped: 0x%x: %s", - error->errnum, error->errmess)); - warn_user("SaveError", error->errmess); - return false; - } - return true; -} - -/** -* wrapper for lib function htmlSaveFileFormat; front sets path from -* path + filename in a filesystem-specific way -*/ - -int save_complete_htmlSaveFileFormat(const char *path, const char *filename, - xmlDocPtr cur, const char *encoding, int format) +static void ro_gui_save_set_file_type(const char *path, lwc_string *mime_type) { + int rotype = ro_content_filetype_from_mime_type(mime_type); os_error *error; - int ret; - int len = strlen(path) + strlen(filename) + 2; - char *fullpath = malloc(len); - if (fullpath == NULL){ - warn_user("NoMemory", 0); - return -1; - } - snprintf(fullpath, len, "%s.%s", path, filename); - - ret = htmlSaveFileFormat(fullpath, cur, encoding, format); - error = xosfile_set_type(fullpath, 0xFAF); - if (error) { - LOG(("xosfile_save_stamped: 0x%x: %s", + error = xosfile_set_type(path, rotype); + if (error != NULL) { + LOG(("xosfile_set_type: 0x%x: %s", error->errnum, error->errmess)); - /* Don't warn the user here -- they probably don't care */ } - - free(fullpath); - return ret; } /** @@ -1130,7 +1075,7 @@ bool ro_gui_save_complete(hlcache_handle *h, char *path) content_get_title(h), LINK_ANT, buf)) return false; - return save_complete(h, path); + return save_complete(h, path, ro_gui_save_set_file_type); } bool ro_gui_save_object_native(hlcache_handle *h, char *path) |