annotate scripts/miscellaneous/recycle.m @ 31706:597f3ee61a48 stable

update Octave Project Developers copyright for the new year
author John W. Eaton <jwe@octave.org>
date Fri, 06 Jan 2023 13:11:27 -0500
parents 796f54d4ddbf
children 2e484f9f1f18
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
31706
597f3ee61a48 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30564
diff changeset
3 ## Copyright (C) 2012-2023 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27898
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
13840
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 ##
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8 ## This file is part of Octave.
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
13840
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
13 ## (at your option) any later version.
13840
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 ##
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
18 ## GNU General Public License for more details.
13840
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 ##
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20 ## You should have received a copy of the GNU General Public License
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
13840
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 ## -*- texinfo -*-
22765
01aae08a0105 maint: Rename variables to match documentation in m-files.
Rik <rik@octave.org>
parents: 22755
diff changeset
27 ## @deftypefn {} {@var{val} =} recycle ()
01aae08a0105 maint: Rename variables to match documentation in m-files.
Rik <rik@octave.org>
parents: 22755
diff changeset
28 ## @deftypefnx {} {@var{old_val} =} recycle (@var{new_val})
13918
043aead8ed89 Remove recycle from list of unimplemented functions
Rik <octave@nomad.inbox5.com>
parents: 13840
diff changeset
29 ## Query or set the preference for recycling deleted files.
13840
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 ##
19191
6cf253a39fde recycle.m: Overhaul function.
Rik <rik@octave.org>
parents: 17744
diff changeset
31 ## When recycling is enabled, commands which would permanently erase files
6cf253a39fde recycle.m: Overhaul function.
Rik <rik@octave.org>
parents: 17744
diff changeset
32 ## instead move them to a temporary location (such as the directory labeled
6cf253a39fde recycle.m: Overhaul function.
Rik <rik@octave.org>
parents: 17744
diff changeset
33 ## Trash).
6cf253a39fde recycle.m: Overhaul function.
Rik <rik@octave.org>
parents: 17744
diff changeset
34 ##
19405
cbce5d1bcaf9 doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 19191
diff changeset
35 ## Programming Note: This function is provided for @sc{matlab} compatibility,
cbce5d1bcaf9 doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 19191
diff changeset
36 ## but recycling is not implemented in Octave. To help avoid accidental data
20164
df437a52bcaf doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
37 ## loss an error will be raised if an attempt is made to enable file recycling.
19191
6cf253a39fde recycle.m: Overhaul function.
Rik <rik@octave.org>
parents: 17744
diff changeset
38 ## @seealso{delete, rmdir}
13840
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 ## @end deftypefn
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40
22765
01aae08a0105 maint: Rename variables to match documentation in m-files.
Rik <rik@octave.org>
parents: 22755
diff changeset
41 function val = recycle (new_val)
13840
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 persistent current_state = "off";
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 if (nargin == 0 || nargout > 0)
22765
01aae08a0105 maint: Rename variables to match documentation in m-files.
Rik <rik@octave.org>
parents: 22755
diff changeset
46 val = current_state;
13840
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47 endif
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 if (nargin == 1)
22765
01aae08a0105 maint: Rename variables to match documentation in m-files.
Rik <rik@octave.org>
parents: 22755
diff changeset
50 if (! ischar (new_val))
01aae08a0105 maint: Rename variables to match documentation in m-files.
Rik <rik@octave.org>
parents: 22755
diff changeset
51 error ("recycle: NEW_VAL must be a character string");
19191
6cf253a39fde recycle.m: Overhaul function.
Rik <rik@octave.org>
parents: 17744
diff changeset
52 endif
19597
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19405
diff changeset
53
22765
01aae08a0105 maint: Rename variables to match documentation in m-files.
Rik <rik@octave.org>
parents: 22755
diff changeset
54 if (strcmpi (new_val, "on"))
19191
6cf253a39fde recycle.m: Overhaul function.
Rik <rik@octave.org>
parents: 17744
diff changeset
55 error ("recycle: recycling files is not implemented");
22765
01aae08a0105 maint: Rename variables to match documentation in m-files.
Rik <rik@octave.org>
parents: 22755
diff changeset
56 elseif (strcmpi (new_val, "off"))
19191
6cf253a39fde recycle.m: Overhaul function.
Rik <rik@octave.org>
parents: 17744
diff changeset
57 current_state = "off";
13840
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58 else
22765
01aae08a0105 maint: Rename variables to match documentation in m-files.
Rik <rik@octave.org>
parents: 22755
diff changeset
59 error ("recycle: invalid value '%s'", new_val);
13840
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60 endif
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61 endif
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63 endfunction
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66 %!test
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67 %! recycle ("off");
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68 %! assert (recycle ("off"), "off");
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
69
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
70 %!error recycle ("on", "and I mean it")
22765
01aae08a0105 maint: Rename variables to match documentation in m-files.
Rik <rik@octave.org>
parents: 22755
diff changeset
71 %!error <NEW_VAL must be a character string> recycle (1)
19191
6cf253a39fde recycle.m: Overhaul function.
Rik <rik@octave.org>
parents: 17744
diff changeset
72 %!error <recycling files is not implemented> recycle ("on")
22765
01aae08a0105 maint: Rename variables to match documentation in m-files.
Rik <rik@octave.org>
parents: 22755
diff changeset
73 %!error <invalid value 'foobar'> recycle ("foobar")