octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patch for copyfile/movefile under Win32


From: michael . goffioul
Subject: Patch for copyfile/movefile under Win32
Date: Wed, 22 Nov 2006 12:39:39 +0100

This patch implements copyfile and movefile in a slighlty more flexible way to
support Win32 (without underlying shell). A more complex implementation would
be to follow the same idea as "ls".
 
Michael.
 
Index: scripts/miscellaneous/copyfile.m
===================================================================
RCS file: /cvs/octave/scripts/miscellaneous/copyfile.m,v
retrieving revision 1.3
diff -c -p -r1.3 copyfile.m
*** scripts/miscellaneous/copyfile.m    11 Nov 2006 19:07:17 -0000      1.3
--- scripts/miscellaneous/copyfile.m    22 Nov 2006 11:37:01 -0000
*************** function [status, msg, msgid] = copyfile
*** 37,47 ****
    msg = "";
    msgid = "";
 
    if (nargin == 2 || nargin == 3)
      if (nargin == 3 && strcmp (force, "f"))
!       cmd = "/bin/cp -rf";
!     else
!       cmd = "/bin/cp -r";
      endif
 
      ## Allow cell input and! protect the file name(s).
--- 37,53 ----
    msg = "";
    msgid = "";
 
+   if (ispc () && ! isunix () && isempty (file_in_path (EXEC_PATH, "cp")))
+     cmd = "cmd /C xcopy /E";
+     cmd_force_flag = "/Y";
+   else
+     cmd = "cp -r";
+     cmd_force_flag = "-f";
+   endif
+
    if (nargin == 2 || nargin == 3)
      if (nargin == 3 && strcmp (force, "f"))
!       cmd = [cmd, " ", cmd_force_flag];
      endif
 
      ## Allow cell input and protect the file name(s).
Index: scripts/miscellaneous/movefile.m
===================================================================
RCS file: /cvs/octave/scripts/miscellaneous/movefile.m,v
retrieving revision 1.2
diff -c -p -r1.2 movefile.m
*** scripts/miscellaneous/movefile.m    21 Oct 2006 14:33:53 -0000      1.2
--- scripts/miscellaneous/movefile.m    22 Nov 2006 11:37:01 -0000
*************** function [status, msg, msgid] = movefile
*** 36,46 ****
    msg = "";
    msgid = "";
 
    if (nargin == 2 || nargin == 3)
      if (nargin == 3 && strcmp (force, "f"))
!       cmd = "/bin/mv -f";
!     else
!       cmd = "/bin/mv";
      endif
 
      ## Allow cell input and protect the file name(s).
--- 36,52 ----
    msg = "";
    msgid = "";
 
+   if (ispc () && ! isunix () && isempty (file_in_path (EXEC_PATH, "mv")))
+     cmd = "cmd /C move";
+     cmd_force_flag = "/Y";
+   else
+     cmd = "mv";
+     cmd_force_flag = "-f";
+   endif
+
    if (nargin == 2 || nargin == 3)
      if (nargin == 3 && strcmp (force, "f"))
!       cmd = [cmd, " ", cmd_force_flag];
      endif
 
      ## Allow cell input and protect the file name(s).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]