Mercurial > hg > octave-lojdl
changeset 8152:2b48deec1aa2
imfinfo.m: delete temporary files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 26 Sep 2008 13:18:13 -0400 |
parents | 3725f819b5b3 |
children | ec0a13863eb7 |
files | scripts/ChangeLog scripts/image/imfinfo.m |
diffstat | 2 files changed, 40 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2008-09-26 John W. Eaton <jwe@octave.org> + + * image/imfinfo.m: Delete temporary file. + 2008-09-25 Søren Hauberg <hauberg@gmail.com> * image/imread.m, image/imwrite.m: Doc fix.
--- a/scripts/image/imfinfo.m +++ b/scripts/image/imfinfo.m @@ -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