Mercurial > octave-nkf
changeset 19225:6cf253a39fde
recycle.m: Overhaul function.
* recycle.m: Redo docstring. Put input validation first.
Add more input validation BIST tests.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 30 Sep 2014 11:18:31 -0700 |
parents | 7bc6fa304f67 |
children | 8a8a7bc2a09d |
files | scripts/miscellaneous/recycle.m |
diffstat | 1 files changed, 19 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/miscellaneous/recycle.m Tue Sep 30 11:08:24 2014 -0700 +++ b/scripts/miscellaneous/recycle.m Tue Sep 30 11:18:31 2014 -0700 @@ -21,10 +21,14 @@ ## @deftypefnx {Function File} {@var{old_state} =} recycle (@var{new_state}) ## Query or set the preference for recycling deleted files. ## -## Recycling files, instead of permanently deleting them, is not currently -## implemented in Octave. To help avoid accidental data loss an error -## will be raised if an attempt is made to enable file recycling. -## @seealso{delete} +## When recycling is enabled, commands which would permanently erase files +## instead move them to a temporary location (such as the directory labeled +## Trash). +## +## Programming Note: This function is provided for Matlab compatibility, but +## recycling is not implemented in Octave. To help avoid accidental data loss +## an error will be raised if an attempt is made to enable file recycling. +## @seealso{delete, rmdir} ## @end deftypefn ## Author: jwe @@ -42,16 +46,16 @@ endif if (nargin == 1) - if (ischar (state)) - if (strcmpi (state, "on")) - error ("recycle: recycling files is not implemented"); - elseif (strcmpi (state, "off")) - current_state = "off"; - else - error ("recycle: invalid value of STATE = '%s'", state); - endif + if (! ischar (state)) + error ("recycle: STATE must be a character string"); + endif + + if (strcmpi (state, "on")) + error ("recycle: recycling files is not implemented"); + elseif (strcmpi (state, "off")) + current_state = "off"; else - error ("recycle: STATE must be a character string"); + error ("recycle: invalid value of STATE = '%s'", state); endif endif @@ -62,7 +66,8 @@ %! recycle ("off"); %! assert (recycle ("off"), "off"); -%!error <recycling files is not implemented> recycle ("on") %!error recycle ("on", "and I mean it") %!error <STATE must be a character string> recycle (1) +%!error <recycling files is not implemented> recycle ("on") +%!error <invalid value of STATE = 'foobar'> recycle ("foobar")