Mercurial > hg > octave-nkf
annotate scripts/miscellaneous/fileattrib.m @ 15107:03381a36f70d
generate convenience libraries for new parse-tree and interpfcn subdirectories
* src/Makefile.am (liboctinterp_la_SOURCES): Include octave.cc in the
list, not $(DIST_SRC).
(liboctinterp_la_LIBADD): Include octave-value/liboctave-value.la,
parse-tree/libparse-tree.la, interp-core/libinterp-core.la,
interpfcn/libinterpfcn.la, and corefcn/libcorefcn.la in the list.
* src/interp-core/module.mk (noinst_LTLIBRARIES): Add
interp-core/libinterp-core.la to the list.
(interp_core_libinterp_core_la_SOURCES): New variable.
* src/interpfcn/module.mk (noinst_LTLIBRARIES): Add
interpfcn/libinterpfcn.la to the list.
(interpfcn_libinterpfcn_la_SOURCES): New variable.
* src/parse-tree/module.mk (noinst_LTLIBRARIES): Add
parse-tree/libparse-tree.la to the list.
(parse_tree_libparse_tree_la_SOURCES): New variable.
* src/octave-value/module.mk (noinst_LTLIBRARIES): Add
octave-value/liboctave-value.la to the list.
(octave_value_liboctave_value_la_SOURCES): New variable.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 05 Aug 2012 09:04:30 -0400 |
parents | 8f0e3c5bfa5f |
children | d6499c14021c |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14064
diff
changeset
|
1 ## Copyright (C) 2005-2012 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 ## | |
23 ## If successful, @var{status} is 1, with @var{result} containing a | |
24 ## structure with the following fields: | |
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 ## |
5559 | 42 ## @item UserRead |
43 ## @itemx GroupRead | |
44 ## @itemx OtherRead | |
45 ## True if the user (group; other users) has read permission for | |
46 ## @var{file}. | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
47 ## |
5559 | 48 ## @item UserWrite |
49 ## @itemx GroupWrite | |
50 ## @itemx OtherWrite | |
51 ## True if the user (group; other users) has write permission for | |
52 ## @var{file}. | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
53 ## |
5559 | 54 ## @item UserExecute |
55 ## @itemx GroupExecute | |
56 ## @itemx OtherExecute | |
57 ## True if the user (group; other users) has execute permission for | |
58 ## @var{file}. | |
59 ## @end table | |
15007
8f0e3c5bfa5f
doc: Periodic grammarcheck of documentation
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
60 ## |
5559 | 61 ## If an attribute does not apply (i.e., archive on a Unix system) then |
62 ## the field is set to NaN. | |
63 ## | |
64 ## With no input arguments, return information about the current | |
65 ## directory. | |
66 ## | |
67 ## If @var{file} contains globbing characters, return information about | |
68 ## all the matching files. | |
69 ## @seealso{glob} | |
70 ## @end deftypefn | |
71 | |
72 function [status, msg, msgid] = fileattrib (file) | |
73 | |
74 status = true; | |
75 msg = ""; | |
76 msgid = ""; | |
77 | |
78 if (nargin == 0) | |
79 file = "."; | |
80 endif | |
81 | |
82 if (ischar (file)) | |
83 files = glob (file); | |
84 if (isempty (files)) | |
85 files = {file}; | |
86 nfiles = 1; | |
87 else | |
88 nfiles = length (files); | |
89 endif | |
90 else | |
91 error ("fileattrib: expecting first argument to be a character string"); | |
92 endif | |
93 | |
94 if (nargin == 0 || nargin == 1) | |
95 | |
96 r_n = r_a = r_s = r_h = r_d ... | |
10549 | 97 = r_u_r = r_u_w = r_u_x ... |
98 = r_g_r = r_g_w = r_g_x ... | |
99 = r_o_r = r_o_w = r_o_x = cell (nfiles, 1); | |
5559 | 100 |
101 curr_dir = pwd (); | |
102 | |
103 for i = 1:nfiles | |
104 [info, err, msg] = stat (files{i}); | |
105 if (! err) | |
10549 | 106 r_n{i} = canonicalize_file_name (files{i}); |
107 r_a{i} = NaN; | |
108 r_s{i} = NaN; | |
109 r_h{i} = NaN; | |
110 r_d{i} = S_ISDIR (info.mode); | |
111 ## FIXME -- maybe we should have S_IRUSR etc. masks? | |
112 modestr = info.modestr; | |
113 r_u_r{i} = modestr(2) == "r"; | |
114 r_u_w{i} = modestr(3) == "w"; | |
115 r_u_x{i} = modestr(4) == "x"; | |
116 r_g_r{i} = modestr(5) == "r"; | |
117 r_g_w{i} = modestr(6) == "w"; | |
118 r_g_x{i} = modestr(7) == "x"; | |
119 r_o_r{i} = modestr(8) == "r"; | |
120 r_o_w{i} = modestr(9) == "w"; | |
121 r_o_x{i} = modestr(10) == "x"; | |
5559 | 122 else |
10549 | 123 status = false; |
124 msgid = "fileattrib"; | |
125 break; | |
5559 | 126 endif |
127 endfor | |
128 if (status) | |
129 r = struct ("Name", r_n, "archive", r_a, "system", r_s, | |
10549 | 130 "hidden", r_s, "directory", r_d, "UserRead", r_u_r, |
131 "UserWrite", r_u_w, "UserExecute", r_u_x, | |
132 "GroupRead", r_g_r, "GroupWrite", r_g_w, | |
133 "GroupExecute", r_g_x, "OtherRead", r_o_r, | |
134 "OtherWrite", r_o_w, "OtherExecute", r_o_x); | |
5559 | 135 if (nargout == 0) |
10549 | 136 status = r; |
5559 | 137 else |
10549 | 138 msg = r; |
5559 | 139 endif |
140 endif | |
141 else | |
6046 | 142 print_usage (); |
5559 | 143 endif |
144 | |
145 endfunction |