Mercurial > hg > octave-jordi
annotate src/oct-fstrm.cc @ 10315:57a59eae83cc
untabify src C++ source files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 11 Feb 2010 12:41:46 -0500 |
parents | cd96d29c5efa |
children | 479cc8a0a846 |
rev | line source |
---|---|
2081 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2007 |
4 John W. Eaton | |
2081 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
2081 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
2081 | 21 |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include <config.h> | |
26 #endif | |
27 | |
28 #include <cerrno> | |
29 #include <cstring> | |
30 | |
31 #include "error.h" | |
32 #include "oct-fstrm.h" | |
33 | |
3340 | 34 octave_stream |
3570 | 35 octave_fstream::create (const std::string& nm_arg, std::ios::openmode arg_md, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
36 oct_mach_info::float_format ff) |
3340 | 37 { |
4587 | 38 return octave_stream (new octave_fstream (nm_arg, arg_md, ff)); |
3340 | 39 } |
40 | |
3552 | 41 octave_fstream::octave_fstream (const std::string& nm_arg, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
42 std::ios::openmode arg_md, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
43 oct_mach_info::float_format ff) |
4587 | 44 : octave_base_stream (arg_md, ff), nm (nm_arg) |
2081 | 45 { |
3775 | 46 |
47 #if CXX_ISO_COMPLIANT_LIBRARY | |
48 | |
49 fs.open (nm.c_str (), arg_md); | |
50 | |
51 #else | |
2081 | 52 // Override default protection of 0664 so that umask will appear to |
53 // do the right thing. | |
54 | |
3570 | 55 fs.open (nm.c_str (), arg_md, 0666); |
2081 | 56 |
3775 | 57 #endif |
58 | |
2081 | 59 if (! fs) |
3531 | 60 { |
61 using namespace std; | |
62 | |
63 error (strerror (errno)); | |
64 } | |
2081 | 65 } |
66 | |
67 // Position a stream at OFFSET relative to ORIGIN. | |
68 | |
69 int | |
4797 | 70 octave_fstream::seek (long, int) |
2081 | 71 { |
4797 | 72 error ("fseek: invalid_operation"); |
73 return -1; | |
2081 | 74 } |
75 | |
76 // Return current stream position. | |
77 | |
4797 | 78 long |
79 octave_fstream::tell (void) | |
2081 | 80 { |
4797 | 81 error ("ftell: invalid_operation"); |
82 return -1; | |
2081 | 83 } |
84 | |
85 // Return non-zero if EOF has been reached on this stream. | |
86 | |
87 bool | |
88 octave_fstream::eof (void) const | |
89 { | |
90 return fs.eof (); | |
91 } | |
92 | |
3652 | 93 void |
94 octave_fstream::do_close (void) | |
95 { | |
96 fs.close (); | |
97 } | |
98 | |
3523 | 99 std::istream * |
2081 | 100 octave_fstream::input_stream (void) |
101 { | |
3523 | 102 std::istream *retval = 0; |
2081 | 103 |
3544 | 104 if (mode () & std::ios::in) |
2081 | 105 retval = &fs; |
106 | |
107 return retval; | |
108 } | |
109 | |
3523 | 110 std::ostream * |
2081 | 111 octave_fstream::output_stream (void) |
112 { | |
3523 | 113 std::ostream *retval = 0; |
2081 | 114 |
3544 | 115 if (mode () & std::ios::out) |
2081 | 116 retval = &fs; |
117 | |
118 return retval; | |
119 } |