Mercurial > hg > octave-jordi
annotate libinterp/corefcn/oct-fstrm.cc @ 20940:a4f5da7c5463
maint: Replace "octave_value_list ()" with "ovl ()".
* debug.cc, det.cc, ellipj.cc, error.cc, file-io.cc, graphics.cc, hess.cc,
input.cc, inv.cc, load-path.cc, lu.cc, octave-link.cc, pager.cc, pinv.cc,
pr-output.cc, profiler.cc, schur.cc, symtab.cc, sysdep.cc, urlwrite.cc,
variables.cc, __magick_read__.cc, audioread.cc, chol.cc, ov-classdef.h,
ov-cs-list.cc, ov-flt-re-mat.cc, ov-re-mat.cc, ov-usr-fcn.cc:
maint: Replace "octave_value_list ()" with "ovl ()".
author | Rik <rik@octave.org> |
---|---|
date | Fri, 18 Dec 2015 16:18:41 -0800 |
parents | aac911d8847b |
children |
rev | line source |
---|---|
2081 | 1 /* |
2 | |
19696
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
18816
diff
changeset
|
3 Copyright (C) 1996-2015 John W. Eaton |
2081 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
2081 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
2081 | 20 |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
27 #include <cerrno> | |
10463
bbe99b2a5ba7
undo recent gnulib-related changes
John W. Eaton <jwe@octave.org>
parents:
10447
diff
changeset
|
28 #include <cstring> |
2081 | 29 |
30 #include "error.h" | |
31 #include "oct-fstrm.h" | |
32 | |
3340 | 33 octave_stream |
3570 | 34 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
|
35 oct_mach_info::float_format ff) |
3340 | 36 { |
4587 | 37 return octave_stream (new octave_fstream (nm_arg, arg_md, ff)); |
3340 | 38 } |
39 | |
3552 | 40 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
|
41 std::ios::openmode arg_md, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
42 oct_mach_info::float_format ff) |
4587 | 43 : octave_base_stream (arg_md, ff), nm (nm_arg) |
2081 | 44 { |
3775 | 45 |
46 #if CXX_ISO_COMPLIANT_LIBRARY | |
47 | |
48 fs.open (nm.c_str (), arg_md); | |
49 | |
50 #else | |
2081 | 51 // Override default protection of 0664 so that umask will appear to |
52 // do the right thing. | |
53 | |
3570 | 54 fs.open (nm.c_str (), arg_md, 0666); |
2081 | 55 |
3775 | 56 #endif |
57 | |
2081 | 58 if (! fs) |
20937
aac911d8847b
choose correct error function in stream classes
John W. Eaton <jwe@octave.org>
parents:
20930
diff
changeset
|
59 // Note: error is inherited from octave_base_stream, not ::error. |
10411 | 60 error (gnulib::strerror (errno)); |
2081 | 61 } |
62 | |
63 // Position a stream at OFFSET relative to ORIGIN. | |
64 | |
65 int | |
16011
8122286c69a9
initial large file support for 32-bit systems
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
66 octave_fstream::seek (off_t, int) |
2081 | 67 { |
20937
aac911d8847b
choose correct error function in stream classes
John W. Eaton <jwe@octave.org>
parents:
20930
diff
changeset
|
68 // Note: error is inherited from octave_base_stream, not ::error. |
20930
69dcb58b9ada
Clean up use of error() versus ::error() in stream-based code.
Rik <rik@octave.org>
parents:
20915
diff
changeset
|
69 // This error function does not halt execution so "return ..." must exist. |
4797 | 70 error ("fseek: invalid_operation"); |
20915
8ddb11c0b1f8
restore return statements after calls to octave_base_stream::error
John W. Eaton <jwe@octave.org>
parents:
20892
diff
changeset
|
71 return -1; |
2081 | 72 } |
73 | |
74 // Return current stream position. | |
75 | |
16011
8122286c69a9
initial large file support for 32-bit systems
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
76 off_t |
4797 | 77 octave_fstream::tell (void) |
2081 | 78 { |
20937
aac911d8847b
choose correct error function in stream classes
John W. Eaton <jwe@octave.org>
parents:
20930
diff
changeset
|
79 // Note: error is inherited from octave_base_stream, not ::error. |
20930
69dcb58b9ada
Clean up use of error() versus ::error() in stream-based code.
Rik <rik@octave.org>
parents:
20915
diff
changeset
|
80 // This error function does not halt execution so "return ..." must exist. |
4797 | 81 error ("ftell: invalid_operation"); |
20915
8ddb11c0b1f8
restore return statements after calls to octave_base_stream::error
John W. Eaton <jwe@octave.org>
parents:
20892
diff
changeset
|
82 return -1; |
2081 | 83 } |
84 | |
18816
9ac2357f19bc
doc: Replace "non-zero" with "nonzero" to match existing usage.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
85 // Return nonzero if EOF has been reached on this stream. |
2081 | 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 } |