Mercurial > octave
diff scripts/miscellaneous/movefile.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/movefile.m Wed Oct 13 17:59:06 2021 +0200 +++ b/scripts/miscellaneous/movefile.m Wed Oct 13 10:36:20 2021 -0700 @@ -44,11 +44,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{rename, copyfile, unlink, delete, glob} ## @end deftypefn @@ -59,7 +59,7 @@ endif max_cmd_line = 1024; - sts = 1; + sts = true; msg = ""; msgid = ""; @@ -99,7 +99,7 @@ if (nargout == 0) error ("movefile: 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 = "movefile"; return; @@ -116,7 +116,7 @@ if (nargout == 0) error ("movefile: no files to move"); else - status = 0; + status = false; msg = "no files to move"; msgid = "movefile"; return; @@ -147,7 +147,7 @@ ## Move the file(s). [err, msg] = system (sprintf ('%s %s "%s"', cmd, p1, p2)); if (err != 0) - sts = 0; + sts = false; msgid = "movefile"; endif ## Load new file(s) in editor @@ -165,7 +165,7 @@ ## Move the file(s). [err, msg] = system (sprintf ('%s %s "%s"', cmd, p1, p2)); if (err != 0) - sts = 0; + sts = false; msgid = "movefile"; endif ## Load new file(s) in editor @@ -173,7 +173,7 @@ endif if (nargout == 0) - if (sts == 0) + if (! sts) error ("movefile: operation failed: %s", msg); endif else