Mercurial > octave
diff scripts/miscellaneous/copyfile.m @ 30241:ba4aebad10d1
Return logical status variable from file functions for Matlab compatibility.
* NEWS: Announce change.
* dirfns.cc (Frmdir): Update documentation. Change return status to true/false
rather than 1.0/0.0.
* copyfile.m: Update documentation. Change internal variable "sts" to logical
variable. Change any assignments to status to true/false.
* movefile.m: Update documentation. Change internal variable "sts" to logical
variable. Change any assignments to status to true/false.
* mkdir.m: Update documentation.
* mkdir.m (mkdir_recur): Change internal variable "status" to logical.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 13 Oct 2021 10:36:20 -0700 |
parents | 7854d5752dd2 |
children | 796f54d4ddbf |
line wrap: on
line diff
--- a/scripts/miscellaneous/copyfile.m Wed Oct 13 17:59:06 2021 +0200 +++ b/scripts/miscellaneous/copyfile.m Wed Oct 13 10:36:20 2021 -0700 @@ -38,11 +38,11 @@ ## When the force flag @qcode{'f'} is given any existing files will be ## overwritten without prompting. ## -## If successful, @var{status} is 1, and @var{msg}, @var{msgid} are empty -## character strings (""). Otherwise, @var{status} is 0, @var{msg} contains a -## system-dependent error message, and @var{msgid} contains a unique message -## identifier. Note that the status code is exactly opposite that of the -## @code{system} command. +## If successful, @var{status} is logical 1, and @var{msg}, @var{msgid} are +## empty character strings (""). Otherwise, @var{status} is logical 0, +## @var{msg} contains a system-dependent error message, and @var{msgid} +## contains a unique message identifier. Note that the status code is exactly +## opposite that of the @code{system} command. ## @seealso{movefile, rename, unlink, delete, glob} ## @end deftypefn @@ -53,7 +53,7 @@ endif max_cmd_line = 1024; - sts = 1; + sts = true; msg = ""; msgid = ""; @@ -90,7 +90,7 @@ if (nargout == 0) error ("copyfile: when copying multiple files, F2 must be a directory"); else - status = 0; + status = false; msg = "when copying multiple files, F2 must be a directory"; msgid = "copyfile"; return; @@ -107,7 +107,7 @@ if (nargout == 0) error ("copyfile: no files to move"); else - status = 0; + status = false; msg = "no files to move"; msgid = "copyfile"; return; @@ -136,7 +136,7 @@ ## Copy the files. [err, msg] = system (sprintf ('%s %s"%s"', cmd, p1, p2)); if (err != 0) - sts = 0; + sts = false; msgid = "copyfile"; break; endif @@ -151,13 +151,13 @@ ## Copy the files. [err, msg] = system (sprintf ('%s %s"%s"', cmd, p1, p2)); if (err != 0) - sts = 0; + sts = false; msgid = "copyfile"; endif endif if (nargout == 0) - if (sts == 0) + if (! sts) error ("copyfile: operation failed: %s", msg); endif else