changeset 19713:f1270e5a3117

__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.
author Rik <rik@octave.org>
date Sun, 08 Feb 2015 10:33:56 -0800
parents c17e1cefdbd3
children 890ff06d84ce
files scripts/plot/util/private/__ghostscript__.m
diffstat 1 files changed, 18 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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)