Mercurial > octave-libgccjit
comparison src/file-io.cc @ 4797:19b8225bdaa2
[project @ 2004-02-23 22:10:31 by jwe]
author | jwe |
---|---|
date | Mon, 23 Feb 2004 22:10:32 +0000 |
parents | 14dc2267c343 |
children | da0d1c453971 |
comparison
equal
deleted
inserted
replaced
4796:962457f25a6d | 4797:19b8225bdaa2 |
---|---|
36 | 36 |
37 #ifdef HAVE_CONFIG_H | 37 #ifdef HAVE_CONFIG_H |
38 #include <config.h> | 38 #include <config.h> |
39 #endif | 39 #endif |
40 | 40 |
41 #include <cerrno> | |
41 #include <climits> | 42 #include <climits> |
42 #include <cerrno> | 43 #include <cstdio> |
43 | 44 |
44 #include <iostream> | 45 #include <iostream> |
45 #include <vector> | 46 #include <vector> |
46 | 47 |
47 #ifdef HAVE_UNISTD_H | 48 #ifdef HAVE_UNISTD_H |
335 if (! error_state) | 336 if (! error_state) |
336 { | 337 { |
337 oct_mach_info::float_format flt_fmt = | 338 oct_mach_info::float_format flt_fmt = |
338 oct_mach_info::string_to_float_format (arch); | 339 oct_mach_info::string_to_float_format (arch); |
339 | 340 |
340 if (! error_state) | 341 FILE *fptr = ::fopen (name.c_str (), mode.c_str ()); |
341 retval = octave_fstream::create (name, md, flt_fmt); | 342 |
343 if (fptr) | |
344 { | |
345 if (! error_state) | |
346 retval = octave_stdiostream::create (name, fptr, md, flt_fmt); | |
347 } | |
348 else | |
349 error ("fopen: failed to open file %s", name.c_str ()); | |
342 } | 350 } |
343 | 351 |
344 return retval; | 352 return retval; |
345 } | 353 } |
346 | 354 |
636 @deftypefn {Built-in Function} {} ftell (@var{fid})\n\ | 644 @deftypefn {Built-in Function} {} ftell (@var{fid})\n\ |
637 Return the position of the file pointer as the number of characters\n\ | 645 Return the position of the file pointer as the number of characters\n\ |
638 from the beginning of the file @var{fid}.\n\ | 646 from the beginning of the file @var{fid}.\n\ |
639 @end deftypefn") | 647 @end deftypefn") |
640 { | 648 { |
641 octave_value retval = streamoff_array (dim_vector (1, 1), -1); | 649 octave_value retval = -1; |
642 | 650 |
643 int nargin = args.length (); | 651 int nargin = args.length (); |
644 | 652 |
645 if (nargin == 1) | 653 if (nargin == 1) |
646 { | 654 { |
647 octave_stream os = octave_stream_list::lookup (args(0), "ftell"); | 655 octave_stream os = octave_stream_list::lookup (args(0), "ftell"); |
648 | 656 |
649 if (! error_state) | 657 if (! error_state) |
650 retval = streamoff_array (dim_vector (1, 1), os.tell ()); | 658 retval = os.tell (); |
651 } | 659 } |
652 else | 660 else |
653 print_usage ("ftell"); | 661 print_usage ("ftell"); |
654 | 662 |
655 return retval; | 663 return retval; |