Mercurial > octave-antonio
annotate scripts/miscellaneous/fileattrib.m @ 20164:df437a52bcaf stable
doc: Update more docstrings to have one sentence summary as first line.
Reviewed miscellaneous, sparse, strings in scripts directory.
* scripts/miscellaneous/bzip2.m, scripts/miscellaneous/citation.m,
scripts/miscellaneous/compare_versions.m, scripts/miscellaneous/computer.m,
scripts/miscellaneous/debug.m, scripts/miscellaneous/dir.m,
scripts/miscellaneous/edit.m, scripts/miscellaneous/error_ids.m,
scripts/miscellaneous/fileattrib.m, scripts/miscellaneous/fullfile.m,
scripts/miscellaneous/genvarname.m, scripts/miscellaneous/gzip.m,
scripts/miscellaneous/mkoctfile.m, scripts/miscellaneous/news.m,
scripts/miscellaneous/open.m, scripts/miscellaneous/parseparams.m,
scripts/miscellaneous/recycle.m, scripts/miscellaneous/run.m,
scripts/miscellaneous/swapbytes.m, scripts/miscellaneous/tar.m,
scripts/miscellaneous/tmpnam.m, scripts/miscellaneous/unpack.m,
scripts/miscellaneous/what.m, scripts/sparse/bicg.m, scripts/sparse/bicgstab.m,
scripts/sparse/cgs.m, scripts/sparse/colperm.m, scripts/sparse/eigs.m,
scripts/sparse/etreeplot.m, scripts/sparse/gmres.m, scripts/sparse/gplot.m,
scripts/sparse/ichol.m, scripts/sparse/ilu.m, scripts/sparse/pcg.m,
scripts/sparse/pcr.m, scripts/sparse/qmr.m, scripts/sparse/spaugment.m,
scripts/sparse/spconvert.m, scripts/sparse/spdiags.m, scripts/sparse/spfun.m,
scripts/sparse/spones.m, scripts/sparse/sprandsym.m, scripts/sparse/spstats.m,
scripts/sparse/spy.m, scripts/sparse/svds.m, scripts/sparse/treelayout.m,
scripts/sparse/treeplot.m, scripts/strings/base2dec.m,
scripts/strings/bin2dec.m, scripts/strings/blanks.m, scripts/strings/cstrcat.m,
scripts/strings/deblank.m, scripts/strings/dec2base.m,
scripts/strings/dec2bin.m, scripts/strings/dec2hex.m,
scripts/strings/findstr.m, scripts/strings/hex2dec.m, scripts/strings/index.m,
scripts/strings/isletter.m, scripts/strings/isstrprop.m,
scripts/strings/mat2str.m, scripts/strings/ostrsplit.m,
scripts/strings/regexptranslate.m, scripts/strings/rindex.m,
scripts/strings/str2num.m, scripts/strings/strcat.m, scripts/strings/strchr.m,
scripts/strings/strjoin.m, scripts/strings/strjust.m,
scripts/strings/strmatch.m, scripts/strings/strsplit.m,
scripts/strings/strtok.m, scripts/strings/strtrim.m,
scripts/strings/strtrunc.m, scripts/strings/substr.m,
scripts/strings/untabify.m, scripts/time/datenum.m:
Update more docstrings to have one sentence summary as first line.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 04 May 2015 14:22:02 -0700 |
parents | 4197fc428c7d |
children |
rev | line source |
---|---|
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
18857
diff
changeset
|
1 ## Copyright (C) 2005-2015 John W. Eaton |
5559 | 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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
5559 | 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 | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
5559 | 18 |
19 ## -*- texinfo -*- | |
14064
0b748d4284de
fileattrib: fix on documentation
Carnë Draug <carandraug+dev@gmail.com>
parents:
11523
diff
changeset
|
20 ## @deftypefn {Function File} {[@var{status}, @var{result}, @var{msgid}] =} fileattrib (@var{file}) |
5559 | 21 ## Return information about @var{file}. |
22 ## | |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
23 ## If successful, @var{status} is 1, with @var{result} containing a structure |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
24 ## with the following fields: |
5559 | 25 ## |
26 ## @table @code | |
27 ## @item Name | |
28 ## Full name of @var{file}. | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
29 ## |
5559 | 30 ## @item archive |
31 ## True if @var{file} is an archive (Windows). | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
32 ## |
5559 | 33 ## @item system |
34 ## True if @var{file} is a system file (Windows). | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
35 ## |
5559 | 36 ## @item hidden |
37 ## True if @var{file} is a hidden file (Windows). | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
38 ## |
5559 | 39 ## @item directory |
40 ## True if @var{file} is a directory. | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
41 ## |
17170
d6499c14021c
doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
42 ## @item UserRead |
5559 | 43 ## @itemx GroupRead |
44 ## @itemx OtherRead | |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
45 ## True if the user (group; other users) has read permission for @var{file}. |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
46 ## |
17170
d6499c14021c
doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
47 ## @item UserWrite |
5559 | 48 ## @itemx GroupWrite |
49 ## @itemx OtherWrite | |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
50 ## True if the user (group; other users) has write permission for @var{file}. |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
51 ## |
17170
d6499c14021c
doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
52 ## @item UserExecute |
5559 | 53 ## @itemx GroupExecute |
54 ## @itemx OtherExecute | |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
55 ## True if the user (group; other users) has execute permission for @var{file}. |
5559 | 56 ## @end table |
15007
8f0e3c5bfa5f
doc: Periodic grammarcheck of documentation
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
57 ## |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
58 ## If an attribute does not apply (i.e., archive on a Unix system) then the |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
59 ## field is set to NaN. |
5559 | 60 ## |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
61 ## With no input arguments, return information about the current directory. |
5559 | 62 ## |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
63 ## If @var{file} contains globbing characters, return information about all |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
64 ## the matching files. |
5559 | 65 ## @seealso{glob} |
66 ## @end deftypefn | |
67 | |
68 function [status, msg, msgid] = fileattrib (file) | |
69 | |
70 status = true; | |
71 msg = ""; | |
72 msgid = ""; | |
73 | |
74 if (nargin == 0) | |
75 file = "."; | |
76 endif | |
77 | |
78 if (ischar (file)) | |
79 files = glob (file); | |
80 if (isempty (files)) | |
81 files = {file}; | |
82 nfiles = 1; | |
83 else | |
84 nfiles = length (files); | |
85 endif | |
86 else | |
87 error ("fileattrib: expecting first argument to be a character string"); | |
88 endif | |
89 | |
90 if (nargin == 0 || nargin == 1) | |
91 | |
92 r_n = r_a = r_s = r_h = r_d ... | |
10549 | 93 = r_u_r = r_u_w = r_u_x ... |
94 = r_g_r = r_g_w = r_g_x ... | |
95 = r_o_r = r_o_w = r_o_x = cell (nfiles, 1); | |
5559 | 96 |
97 curr_dir = pwd (); | |
98 | |
99 for i = 1:nfiles | |
100 [info, err, msg] = stat (files{i}); | |
101 if (! err) | |
10549 | 102 r_n{i} = canonicalize_file_name (files{i}); |
103 r_a{i} = NaN; | |
104 r_s{i} = NaN; | |
105 r_h{i} = NaN; | |
106 r_d{i} = S_ISDIR (info.mode); | |
18857
7bbe3658c5ef
maint: Use "FIXME:" coding convention in m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
107 ## FIXME: Maybe we should have S_IRUSR etc. masks? |
10549 | 108 modestr = info.modestr; |
109 r_u_r{i} = modestr(2) == "r"; | |
110 r_u_w{i} = modestr(3) == "w"; | |
111 r_u_x{i} = modestr(4) == "x"; | |
112 r_g_r{i} = modestr(5) == "r"; | |
113 r_g_w{i} = modestr(6) == "w"; | |
114 r_g_x{i} = modestr(7) == "x"; | |
115 r_o_r{i} = modestr(8) == "r"; | |
116 r_o_w{i} = modestr(9) == "w"; | |
117 r_o_x{i} = modestr(10) == "x"; | |
5559 | 118 else |
10549 | 119 status = false; |
120 msgid = "fileattrib"; | |
121 break; | |
5559 | 122 endif |
123 endfor | |
124 if (status) | |
125 r = struct ("Name", r_n, "archive", r_a, "system", r_s, | |
10549 | 126 "hidden", r_s, "directory", r_d, "UserRead", r_u_r, |
127 "UserWrite", r_u_w, "UserExecute", r_u_x, | |
128 "GroupRead", r_g_r, "GroupWrite", r_g_w, | |
129 "GroupExecute", r_g_x, "OtherRead", r_o_r, | |
130 "OtherWrite", r_o_w, "OtherExecute", r_o_x); | |
5559 | 131 if (nargout == 0) |
10549 | 132 status = r; |
5559 | 133 else |
10549 | 134 msg = r; |
5559 | 135 endif |
136 endif | |
137 else | |
6046 | 138 print_usage (); |
5559 | 139 endif |
140 | |
141 endfunction | |
17338
1c89599167a6
maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents:
17170
diff
changeset
|
142 |