# HG changeset patch # User Rik # Date 1423420436 28800 # Node ID f1270e5a31178f5a34fe836b0c3c17cee35cd71b # Parent c17e1cefdbd316d59815a13187fa3fafde7dafeb __ghostscript__.m: Use del to remove files on Windows machines (bug #44186). * __ghostscript__.m: Create new variable dos_shell which determines which platform Octave is running on. Use dos_shell var to decide whether to use 'rm' or 'del' to remove files. diff -r c17e1cefdbd3 -r f1270e5a3117 scripts/plot/util/private/__ghostscript__.m --- a/scripts/plot/util/private/__ghostscript__.m Sun Feb 08 18:40:00 2015 +0100 +++ b/scripts/plot/util/private/__ghostscript__.m Sun Feb 08 10:33:56 2015 -0800 @@ -26,6 +26,8 @@ function [gs_cmd, cleanup_cmd] = __ghostscript__ (varargin); + dos_shell = (ispc () && ! isunix ()); + opts.binary = ""; opts.source = "-"; opts.output = "-"; @@ -113,7 +115,11 @@ cleanup_cmd = ""; else offsetfile = [tempname() ".ps"]; - cleanup_cmd = sprintf ("rm %s", offsetfile); + if (dos_shell) + cleanup_cmd = ["del " strrep(offsetfile, '/', '\')]; + else + cleanup_cmd = ["rm " offsetfile]; + endif endif unwind_protect fid = fopen (offsetfile, "w"); @@ -148,9 +154,18 @@ ## http://en.wikibooks.org/wiki/PostScript_FAQ cmd = sprintf ("%s %s", cmd, opts.prepend); if (isempty (cleanup_cmd)) - cleanup_cmd = sprintf ("rm %s", opts.prepend); + if (dos_shell) + cleanup_cmd = ["del " strrep(opts.prepend, '/', '\')]; + else + cleanup_cmd = ["rm " opts.prepend]; + endif else - cleanup_cmd = sprintf ("%s ; rm %s", cleanup_cmd, opts.prepend); + if (dos_shell) + cleanup_cmd = sprintf ("%s & del %s", cleanup_cmd, + strrep (opts.prepend, '/', '\')); + else + cleanup_cmd = sprintf ("%s ; rm %s", cleanup_cmd, opts.prepend); + endif endif endif if (! isempty (offsetfile) && format_for_printer)