Mercurial > hg > octave-nkf
annotate scripts/io/fileread.m @ 10334:db540cb0e959
improve shadowed function checking
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 18 Feb 2010 08:40:17 +0100 |
parents | c146b308739f |
children | be55736a0783 |
rev | line source |
---|---|
10081 | 1 ## Copyright (C) 2010 VZLU Prague |
2 ## | |
3 ## This program is free software; you can redistribute it and/or modify | |
4 ## it under the terms of the GNU General Public License as published by | |
5 ## the Free Software Foundation; either version 3 of the License, or | |
6 ## (at your option) any later version. | |
7 ## | |
8 ## This program is distributed in the hope that it will be useful, | |
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 ## GNU General Public License for more details. | |
12 ## | |
13 ## You should have received a copy of the GNU General Public License | |
14 ## along with this program; if not, see | |
15 ## <http://www.gnu.org/licenses/>. | |
16 | |
17 ## -*- texinfo -*- | |
18 ## @deftypefn {Function File} {@var{str} =} fileread (@var{filename}) | |
19 ## Read the contents of a file and return it as a string. | |
20 ## @seealso{fread, textread} | |
21 ## @end deftypefn | |
22 | |
23 function str = fileread (filename) | |
24 | |
25 if (nargin != 1) | |
26 print_usage (); | |
27 endif | |
28 | |
29 if (! ischar (filename)) | |
30 error ("fileread: argument must be a string"); | |
31 endif | |
32 | |
33 fid = fopen (filename, "r"); | |
34 if (fid < 0) | |
35 error ("fileread: cannot open file"); | |
36 endif | |
37 | |
38 unwind_protect | |
39 str = fread (fid, "*char"); | |
40 unwind_protect_cleanup | |
10110
c146b308739f
missing semicolon in fileread
Jaroslav Hajek <highegg@gmail.com>
parents:
10081
diff
changeset
|
41 fclose (fid); |
10081 | 42 end_unwind_protect |
43 | |
44 endfunction | |
45 |