From ed4d0f2ebcedabd15ebeb73408b69cd314fd1e86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Rameau?= Date: Sat, 28 May 2005 19:00:56 +0000 Subject: Get a temporary filename to save to only when needed. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2005-05-28 Jean-François Rameau * embed/mozilla/mozilla-embed-persist.cpp: (impl_save): Get a temporary filename to save to only when needed. --- ChangeLog | 6 ++++++ embed/mozilla/mozilla-embed-persist.cpp | 28 ++++++++++++++-------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 84f58589c..f8fdc6839 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-05-28 Jean-François Rameau + + * embed/mozilla/mozilla-embed-persist.cpp: (impl_save): + + Get a temporary filename to save to only when needed. + 2005-05-28 Christian Persch * configure.ac: diff --git a/embed/mozilla/mozilla-embed-persist.cpp b/embed/mozilla/mozilla-embed-persist.cpp index 06733ddbe..c10d677ae 100644 --- a/embed/mozilla/mozilla-embed-persist.cpp +++ b/embed/mozilla/mozilla-embed-persist.cpp @@ -177,19 +177,6 @@ impl_save (EphyEmbedPersist *persist) /* we must have one of uri or browser */ g_assert (browser != NULL || uri != NULL); - /* Get a temp filename to save to */ - char *tmp_filename, *base; - base = g_build_filename (g_get_tmp_dir (), "sav-XXXXXX", NULL); - tmp_filename = ephy_file_tmp_filename (base, "html"); - g_free (base); - if (tmp_filename == NULL) return FALSE; - - nsCOMPtr tmpFile = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID); - NS_ENSURE_TRUE (tmpFile, FALSE); - - tmpFile->InitWithNativePath (nsEmbedCString (tmp_filename)); - g_free (tmp_filename); - /* Get the uri to save to */ nsCOMPtr inURI; if (uri) @@ -254,6 +241,19 @@ impl_save (EphyEmbedPersist *persist) if (filename == NULL || filename[0] == '\0') { + /* Get a temp filename to save to */ + char *tmp_filename, *base; + base = g_build_filename (g_get_tmp_dir (), "sav-XXXXXX", NULL); + tmp_filename = ephy_file_tmp_filename (base, "html"); + g_free (base); + if (tmp_filename == NULL) return FALSE; + + nsCOMPtr tmpFile = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID); + NS_ENSURE_TRUE (tmpFile, FALSE); + + tmpFile->InitWithNativePath (nsEmbedCString (tmp_filename)); + g_free (tmp_filename); + /* Create an header sniffer and do the save */ nsCOMPtr webPersist = MOZILLA_EMBED_PERSIST (persist)->priv->mPersist; @@ -263,7 +263,7 @@ impl_save (EphyEmbedPersist *persist) (webPersist, MOZILLA_EMBED_PERSIST (persist), tmpFile, inURI, DOMDocument, postData, single); if (!sniffer) return FALSE; - + webPersist->SetProgressListener(sniffer); rv = webPersist->SaveURI(inURI, pageDescriptor, nsnull, nsnull, nsnull, tmpFile); if (NS_FAILED (rv)) return FALSE; -- cgit v1.2.3