~gabriel1984sibiu/octave/octave

« back to all changes in this revision

Viewing changes to scripts/miscellaneous/recycle.m

  • Committer: Grevutiu Gabriel
  • Date: 2014-01-02 13:05:54 UTC
  • Revision ID: gabriel1984sibiu@gmail.com-20140102130554-3r7ivdjln1ni6kcg
New version (3.8.0) from upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
## Copyright (C) 2012-2013 John W. Eaton
 
2
##
 
3
## This file is part of Octave.
 
4
##
 
5
## Octave is free software; you can redistribute it and/or modify it
 
6
## under the terms of the GNU General Public License as published by
 
7
## the Free Software Foundation; either version 3 of the License, or (at
 
8
## your option) any later version.
 
9
##
 
10
## Octave is distributed in the hope that it will be useful, but
 
11
## WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
## General Public License for more details.
 
14
##
 
15
## You should have received a copy of the GNU General Public License
 
16
## along with Octave; see the file COPYING.  If not, see
 
17
## <http://www.gnu.org/licenses/>.
 
18
 
 
19
## -*- texinfo -*-
 
20
## @deftypefn  {Function File} {@var{current_state} =} recycle ()
 
21
## @deftypefnx {Function File} {@var{old_state} =} recycle (@var{new_state})
 
22
## Query or set the preference for recycling deleted files.
 
23
##
 
24
## Recycling files, instead of permanently deleting them, is not currently
 
25
## implemented in Octave.  To help avoid accidental data loss an error
 
26
## will be raised if an attempt is made to enable file recycling.
 
27
## @seealso{delete}
 
28
## @end deftypefn
 
29
 
 
30
## Author: jwe
 
31
 
 
32
function retval = recycle (state)
 
33
 
 
34
  persistent current_state = "off";
 
35
 
 
36
  if (nargin > 1)
 
37
    print_usage ();
 
38
  endif
 
39
 
 
40
  if (nargin == 0 || nargout > 0)
 
41
    retval = current_state;
 
42
  endif
 
43
 
 
44
  if (nargin == 1)
 
45
    if (ischar (state))
 
46
      if (strcmpi (state, "on"))
 
47
        error ("recycle: recycling files is not implemented");
 
48
      elseif (strcmpi (state, "off"))
 
49
        current_state = "off";
 
50
      else
 
51
        error ("recycle: invalid value of STATE = '%s'", state);
 
52
      endif
 
53
    else
 
54
      error ("recycle: STATE must be a character string");
 
55
    endif
 
56
  endif
 
57
 
 
58
endfunction
 
59
 
 
60
 
 
61
%!test
 
62
%! recycle ("off");
 
63
%! assert (recycle ("off"), "off");
 
64
 
 
65
%!error <recycling files is not implemented> recycle ("on")
 
66
%!error recycle ("on", "and I mean it")
 
67
%!error <STATE must be a character string> recycle (1)
 
68