changeset 16989:7a69ab84b8c9

__magick_write__: confirm file exists before reading to append. * __magick_read__.cc (__magick_write__): when WriteMode is set to append, file needs to be read first. If file does not exist, act normally. Confirm existence to file and skip reading if false.
author Carnë Draug <carandraug@octave.org>
date Tue, 16 Jul 2013 19:39:22 +0100
parents 54b75bed4bc7
children cd0c56969d59
files libinterp/dldfcn/__magick_read__.cc
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/dldfcn/__magick_read__.cc	Tue Jul 16 17:29:45 2013 +0100
+++ b/libinterp/dldfcn/__magick_read__.cc	Tue Jul 16 19:39:22 2013 +0100
@@ -472,7 +472,7 @@
         {
           error ("__magick_read__: invalid value for Index/Frame");
         }
-      // Fix indexex from base 1 to base 0, and at the same time, make
+      // Fix indexes from base 1 to base 0, and at the same time, make
       // sure none of the indexes is outside the range of image number.
       const int n = frameidx.nelem ();
       for (int i = 0; i < n; i++)
@@ -873,7 +873,7 @@
   // read at all.
   const std::string writemode = options.getfield ("writemode")(0).string_value ();
   std::vector<Magick::Image> ini_imvec;
-  if (writemode == "append")
+  if (writemode == "append" && file_stat (filename).exists ())
     {
       read_file (filename, ini_imvec);
       if (error_state)