Mercurial > hg > octave-lyh
annotate scripts/io/fileread.m @ 11587:c792872f8942
all script files: untabify and strip trailing whitespace
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 20 Jan 2011 17:35:29 -0500 |
parents | fd0a3ac60b0e |
children | 3d6584617da0 |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 2010-2011 VZLU Prague |
10081 | 2 ## |
11104 | 3 ## This file is part of Octave. |
10081 | 4 ## |
11104 | 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. | |
10081 | 14 ## |
15 ## You should have received a copy of the GNU General Public License | |
11104 | 16 ## along with Octave; see the file COPYING. If not, see |
10081 | 17 ## <http://www.gnu.org/licenses/>. |
18 | |
19 ## -*- texinfo -*- | |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10110
diff
changeset
|
20 ## @deftypefn {Function File} {@var{str} =} fileread (@var{filename}) |
10081 | 21 ## Read the contents of a file and return it as a string. |
22 ## @seealso{fread, textread} | |
23 ## @end deftypefn | |
24 | |
25 function str = fileread (filename) | |
26 | |
27 if (nargin != 1) | |
28 print_usage (); | |
29 endif | |
30 | |
31 if (! ischar (filename)) | |
32 error ("fileread: argument must be a string"); | |
33 endif | |
34 | |
35 fid = fopen (filename, "r"); | |
36 if (fid < 0) | |
37 error ("fileread: cannot open file"); | |
38 endif | |
39 | |
40 unwind_protect | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
41 str = fread (fid, "*char"); |
10081 | 42 unwind_protect_cleanup |
10110
c146b308739f
missing semicolon in fileread
Jaroslav Hajek <highegg@gmail.com>
parents:
10081
diff
changeset
|
43 fclose (fid); |
10081 | 44 end_unwind_protect |
45 | |
46 endfunction | |
47 |