Mercurial > hg > octave-jordi
diff scripts/miscellaneous/copyfile.m @ 6233:a299c8a6d96e
[project @ 2007-01-09 04:31:18 by jwe]
author | jwe |
---|---|
date | Tue, 09 Jan 2007 04:33:46 +0000 |
parents | 12b676a0b183 |
children | 9bd49ed48ee6 |
line wrap: on
line diff
--- a/scripts/miscellaneous/copyfile.m +++ b/scripts/miscellaneous/copyfile.m @@ -41,6 +41,7 @@ ## over the command that is executed. if (ispc () && ! isunix () && isempty (file_in_path (EXEC_PATH, "cp"))) + ## Windows. cmd = "cmd /C xcopy /E"; cmd_force_flag = "/Y"; else @@ -49,17 +50,29 @@ endif if (nargin == 2 || nargin == 3) + ## Input type check. + if (! (ischar (f1) || iscellstr (f1))) + error ("copyfile: first argument must be a character string or a cell array of character strings"); + endif + + if (! ischar (f2)) + error ("copyfile: second argument must be a character string"); + endif + if (nargin == 3 && strcmp (force, "f")) cmd = strcat (cmd, " ", cmd_force_flag); endif - ## Allow cell input and protect the file name(s). - if (iscellstr (f1)) - f1 = sprintf("\"%s\" ", f1{:}); - else - f1 = sprintf("\"%s\" ", f1); + ## If f1 isn't a cellstr convert it to one. + if (ischar (f1)) + f1 = cellstr (f1); endif + + ## Protect the file name(s). + f1 = glob (f1); + f1 = sprintf ("\"%s\" ", f1{:}); + ## Copy the files. [err, msg] = system (sprintf ("%s %s \"%s\"", cmd, f1, f2)); if (err < 0) status = false;