# HG changeset patch # User John W. Eaton # Date 1222449493 14400 # Node ID 2b48deec1aa2e0a0c54e6516396a2892744e2718 # Parent 3725f819b5b3c023e6c73a98c7a9bdc7aec88aa4 imfinfo.m: delete temporary files diff -r 3725f819b5b3 -r 2b48deec1aa2 scripts/ChangeLog --- a/scripts/ChangeLog Fri Sep 26 13:16:42 2008 -0400 +++ b/scripts/ChangeLog Fri Sep 26 13:18:13 2008 -0400 @@ -1,3 +1,7 @@ +2008-09-26 John W. Eaton + + * image/imfinfo.m: Delete temporary file. + 2008-09-25 Søren Hauberg * image/imread.m, image/imwrite.m: Doc fix. diff -r 3725f819b5b3 -r 2b48deec1aa2 scripts/image/imfinfo.m --- a/scripts/image/imfinfo.m Fri Sep 26 13:16:42 2008 -0400 +++ b/scripts/image/imfinfo.m Fri Sep 26 13:18:13 2008 -0400 @@ -95,26 +95,46 @@ filename = tilde_expand (filename); - fn = file_in_path (IMAGE_PATH, filename); - if (isempty (fn)) - ## Couldn't find file. See if it's an URL. - tmp = tmpnam (); + delete_file = false; + + unwind_protect + + fn = file_in_path (IMAGE_PATH, filename); + + if (isempty (fn)) + + ## Couldn't find file. See if it's an URL. - [fn, status, msg] = urlwrite (filename, tmp); + tmp = tmpnam (); + + [fn, status, msg] = urlwrite (filename, tmp); - if (! status) - error ("imfinfo: cannot find %s", filename); + if (! status) + error ("imfinfo: cannot find %s", filename); + endif + + if (! isempty (fn)) + delete_file = true; + endif + endif - endif + + [statinfo, err, msg] = stat (fn); + if (err != 0) + error ("imfinfo: error reading '%s': %s", fn, msg); + endif - [statinfo, err, msg] = stat (fn); - if (err != 0) - error ("imfinfo: error reading '%s': %s", fn, msg); - endif + time_stamp = strftime ("%e-%b-%Y %H:%M:%S", localtime (statinfo.mtime)); + + info = __magick_finfo__ (fn); + info.FileModDate = time_stamp; - time_stamp = strftime ("%e-%b-%Y %H:%M:%S", localtime (statinfo.mtime)); - - info = __magick_finfo__ (filename); - info.FileModDate = time_stamp; + unwind_protect_cleanup + + if (delete_file) + unlink (fn); + endif + + end_unwind_protect endfunction