comparison src/file-io.cc @ 5642:2618a0750ae6

[project @ 2006-03-06 21:26:48 by jwe]
author jwe
date Mon, 06 Mar 2006 21:26:54 +0000
parents 0f6947621602
children ab9a339fcec8
comparison
equal deleted inserted replaced
5641:eb998631a4aa 5642:2618a0750ae6
190 DEFUN (fclose, args, , 190 DEFUN (fclose, args, ,
191 "-*- texinfo -*-\n\ 191 "-*- texinfo -*-\n\
192 @deftypefn {Built-in Function} {} fclose (@var{fid})\n\ 192 @deftypefn {Built-in Function} {} fclose (@var{fid})\n\
193 Closes the specified file. If successful, @code{fclose} returns 0,\n\ 193 Closes the specified file. If successful, @code{fclose} returns 0,\n\
194 otherwise, it returns -1.\n\ 194 otherwise, it returns -1.\n\
195 @end deftypefn\n\ 195 @seealso{fopen, fseek, ftell}\n\
196 @seealso{fopen, fseek, ftell}") 196 @end deftypefn")
197 { 197 {
198 octave_value retval = -1; 198 octave_value retval = -1;
199 199
200 int nargin = args.length (); 200 int nargin = args.length ();
201 201
240 For example, it is always a good idea to flush the standard output\n\ 240 For example, it is always a good idea to flush the standard output\n\
241 stream before calling @code{input}.\n\ 241 stream before calling @code{input}.\n\
242 \n\ 242 \n\
243 @code{fflush} returns 0 on success and an OS dependent error value\n\ 243 @code{fflush} returns 0 on success and an OS dependent error value\n\
244 (@minus{}1 on unix) on error.\n\ 244 (@minus{}1 on unix) on error.\n\
245 @end deftypefn\n\ 245 @seealso{fopen, fclose}\n\
246 @seealso{fopen, fclose}") 246 @end deftypefn")
247 { 247 {
248 octave_value retval = -1; 248 octave_value retval = -1;
249 249
250 int nargin = args.length (); 250 int nargin = args.length ();
251 251
284 \n\ 284 \n\
285 If @var{len} is omitted, @code{fgetl} reads until the next newline\n\ 285 If @var{len} is omitted, @code{fgetl} reads until the next newline\n\
286 character.\n\ 286 character.\n\
287 \n\ 287 \n\
288 If there are no more characters to read, @code{fgetl} returns @minus{}1.\n\ 288 If there are no more characters to read, @code{fgetl} returns @minus{}1.\n\
289 @end deftypefn\n\ 289 @seealso{fread, fscanf}\n\
290 @seealso{fread, fscanf}") 290 @end deftypefn")
291 { 291 {
292 static std::string who = "fgetl"; 292 static std::string who = "fgetl";
293 293
294 octave_value_list retval; 294 octave_value_list retval;
295 295
333 \n\ 333 \n\
334 If @var{len} is omitted, @code{fgets} reads until the next newline\n\ 334 If @var{len} is omitted, @code{fgets} reads until the next newline\n\
335 character.\n\ 335 character.\n\
336 \n\ 336 \n\
337 If there are no more characters to read, @code{fgets} returns @minus{}1.\n\ 337 If there are no more characters to read, @code{fgets} returns @minus{}1.\n\
338 @end deftypefn\n\ 338 @seealso{fread, fscanf}\n\
339 @seealso{fread, fscanf}") 339 @end deftypefn")
340 { 340 {
341 static std::string who = "fgets"; 341 static std::string who = "fgets";
342 342
343 octave_value_list retval; 343 octave_value_list retval;
344 344
558 @end table\n\ 558 @end table\n\
559 \n\ 559 \n\
560 @noindent\n\ 560 @noindent\n\
561 however, conversions are currently only supported for @samp{native}\n\ 561 however, conversions are currently only supported for @samp{native}\n\
562 @samp{ieee-be}, and @samp{ieee-le} formats.\n\ 562 @samp{ieee-be}, and @samp{ieee-le} formats.\n\
563 @end deftypefn\n\ 563 @seealso{fclose, fread, fseek}\n\
564 @seealso{fclose, fread, fseek}") 564 @end deftypefn")
565 { 565 {
566 octave_value_list retval; 566 octave_value_list retval;
567 567
568 retval(0) = -1.0; 568 retval(0) = -1.0;
569 569
700 file) or strings \"cof\", \"bof\" or \"eof\". If @var{origin} is omitted,\n\ 700 file) or strings \"cof\", \"bof\" or \"eof\". If @var{origin} is omitted,\n\
701 @code{SEEK_SET} is assumed. The offset must be zero, or a value returned\n\ 701 @code{SEEK_SET} is assumed. The offset must be zero, or a value returned\n\
702 by @code{ftell} (in which case @var{origin} must be @code{SEEK_SET}).\n\ 702 by @code{ftell} (in which case @var{origin} must be @code{SEEK_SET}).\n\
703 \n\ 703 \n\
704 Return 0 on success and -1 on error.\n\ 704 Return 0 on success and -1 on error.\n\
705 @end deftypefn\n\ 705 @seealso{ftell, fopen, fclose}\n\
706 @seealso{ftell, fopen, fclose}") 706 @end deftypefn")
707 { 707 {
708 octave_value retval = -1; 708 octave_value retval = -1;
709 709
710 int nargin = args.length (); 710 int nargin = args.length ();
711 711
730 DEFUN (ftell, args, , 730 DEFUN (ftell, args, ,
731 "-*- texinfo -*-\n\ 731 "-*- texinfo -*-\n\
732 @deftypefn {Built-in Function} {} ftell (@var{fid})\n\ 732 @deftypefn {Built-in Function} {} ftell (@var{fid})\n\
733 Return the position of the file pointer as the number of characters\n\ 733 Return the position of the file pointer as the number of characters\n\
734 from the beginning of the file @var{fid}.\n\ 734 from the beginning of the file @var{fid}.\n\
735 @end deftypefn\n\ 735 @seealso{fseek, fopen, fclose}\n\
736 @seealso{fseek, fopen, fclose}") 736 @end deftypefn")
737 { 737 {
738 octave_value retval = -1; 738 octave_value retval = -1;
739 739
740 int nargin = args.length (); 740 int nargin = args.length ();
741 741
755 DEFUN (fprintf, args, nargout, 755 DEFUN (fprintf, args, nargout,
756 "-*- texinfo -*-\n\ 756 "-*- texinfo -*-\n\
757 @deftypefn {Built-in Function} {} fprintf (@var{fid}, @var{template}, @dots{})\n\ 757 @deftypefn {Built-in Function} {} fprintf (@var{fid}, @var{template}, @dots{})\n\
758 This function is just like @code{printf}, except that the output is\n\ 758 This function is just like @code{printf}, except that the output is\n\
759 written to the stream @var{fid} instead of @code{stdout}.\n\ 759 written to the stream @var{fid} instead of @code{stdout}.\n\
760 @end deftypefn\n\ 760 @seealso{printf, sprintf, fread, fscanf, fopen, fclose}\n\
761 @seealso{printf, sprintf, fread, fscanf, fopen, fclose}") 761 @end deftypefn")
762 { 762 {
763 static std::string who = "fprintf"; 763 static std::string who = "fprintf";
764 764
765 octave_value retval; 765 octave_value retval;
766 766
817 @deftypefn {Built-in Function} {} printf (@var{template}, @dots{})\n\ 817 @deftypefn {Built-in Function} {} printf (@var{template}, @dots{})\n\
818 Print optional arguments under the control of the template string\n\ 818 Print optional arguments under the control of the template string\n\
819 @var{template} to the stream @code{stdout}.\n\ 819 @var{template} to the stream @code{stdout}.\n\
820 \n\ 820 \n\
821 Return the number of characters printed.\n\ 821 Return the number of characters printed.\n\
822 @end deftypefn\n\ 822 @seealso{fprintf, sprintf, scanf}\n\
823 @seealso{fprintf, sprintf, scanf}") 823 @end deftypefn")
824 { 824 {
825 static std::string who = "printf"; 825 static std::string who = "printf";
826 826
827 octave_value retval; 827 octave_value retval;
828 828
911 This is like @code{printf}, except that the output is returned as a\n\ 911 This is like @code{printf}, except that the output is returned as a\n\
912 string. Unlike the C library function, which requires you to provide a\n\ 912 string. Unlike the C library function, which requires you to provide a\n\
913 suitably sized string as an argument, Octave's @code{sprintf} function\n\ 913 suitably sized string as an argument, Octave's @code{sprintf} function\n\
914 returns the string, automatically sized to hold all of the items\n\ 914 returns the string, automatically sized to hold all of the items\n\
915 converted.\n\ 915 converted.\n\
916 @end deftypefn\n\ 916 @seealso{printf, fprintf, sscanf}\n\
917 @seealso{printf, fprintf, sscanf}") 917 @end deftypefn")
918 { 918 {
919 static std::string who = "sprintf"; 919 static std::string who = "sprintf";
920 920
921 octave_value_list retval; 921 octave_value_list retval;
922 922
1001 In the second form, read from @var{fid} according to @var{template},\n\ 1001 In the second form, read from @var{fid} according to @var{template},\n\
1002 with each conversion specifier in @var{template} corresponding to a\n\ 1002 with each conversion specifier in @var{template} corresponding to a\n\
1003 single scalar return value. This form is more `C-like', and also\n\ 1003 single scalar return value. This form is more `C-like', and also\n\
1004 compatible with previous versions of Octave. The number of successful\n\ 1004 compatible with previous versions of Octave. The number of successful\n\
1005 conversions is returned in @var{count}\n\ 1005 conversions is returned in @var{count}\n\
1006 @end deftypefn\n\ 1006 @seealso{scanf, sscanf, fread, fprintf}\n\
1007 @seealso{scanf, sscanf, fread, fprintf}") 1007 @end deftypefn")
1008 { 1008 {
1009 static std::string who = "fscanf"; 1009 static std::string who = "fscanf";
1010 1010
1011 octave_value_list retval; 1011 octave_value_list retval;
1012 1012
1067 @deftypefn {Built-in Function} {[@var{val}, @var{count}] =} sscanf (@var{string}, @var{template}, @var{size})\n\ 1067 @deftypefn {Built-in Function} {[@var{val}, @var{count}] =} sscanf (@var{string}, @var{template}, @var{size})\n\
1068 @deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}] = } sscanf (@var{string}, @var{template}, \"C\")\n\ 1068 @deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}] = } sscanf (@var{string}, @var{template}, \"C\")\n\
1069 This is like @code{fscanf}, except that the characters are taken from the\n\ 1069 This is like @code{fscanf}, except that the characters are taken from the\n\
1070 string @var{string} instead of from a stream. Reaching the end of the\n\ 1070 string @var{string} instead of from a stream. Reaching the end of the\n\
1071 string is treated as an end-of-file condition.\n\ 1071 string is treated as an end-of-file condition.\n\
1072 @end deftypefn\n\ 1072 @seealso{fscanf, scanf, sprintf}\n\
1073 @seealso{fscanf, scanf, sprintf}") 1073 @end deftypefn")
1074 { 1074 {
1075 static std::string who = "sscanf"; 1075 static std::string who = "sscanf";
1076 1076
1077 octave_value_list retval; 1077 octave_value_list retval;
1078 1078
1160 @deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}]] = } scanf (@var{template}, \"C\")\n\ 1160 @deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}]] = } scanf (@var{template}, \"C\")\n\
1161 This is equivalent to calling @code{fscanf} with @var{fid} = @code{stdin}.\n\ 1161 This is equivalent to calling @code{fscanf} with @var{fid} = @code{stdin}.\n\
1162 \n\ 1162 \n\
1163 It is currently not useful to call @code{scanf} in interactive\n\ 1163 It is currently not useful to call @code{scanf} in interactive\n\
1164 programs.\n\ 1164 programs.\n\
1165 @end deftypefn\n\ 1165 @seealso{fscanf, sscanf, printf}\n\
1166 @seealso{fscanf, sscanf, printf}") 1166 @end deftypefn")
1167 { 1167 {
1168 int nargin = args.length (); 1168 int nargin = args.length ();
1169 1169
1170 octave_value_list tmp_args (nargin+1, octave_value ()); 1170 octave_value_list tmp_args (nargin+1, octave_value ());
1171 1171
1404 Conversions are currently only supported for @code{\"ieee-be\"} and\n\ 1404 Conversions are currently only supported for @code{\"ieee-be\"} and\n\
1405 @code{\"ieee-le\"} formats.\n\ 1405 @code{\"ieee-le\"} formats.\n\
1406 \n\ 1406 \n\
1407 The data read from the file is returned in @var{val}, and the number of\n\ 1407 The data read from the file is returned in @var{val}, and the number of\n\
1408 values read is returned in @code{count}\n\ 1408 values read is returned in @code{count}\n\
1409 @end deftypefn\n\ 1409 @seealso{fwrite, fopen, fclose}\n\
1410 @seealso{fwrite, fopen, fclose}") 1410 @end deftypefn")
1411 { 1411 {
1412 octave_value_list retval; 1412 octave_value_list retval;
1413 1413
1414 int nargin = args.length (); 1414 int nargin = args.length ();
1415 1415
1516 The remaining arguments @var{precision}, @var{skip}, and @var{arch} are\n\ 1516 The remaining arguments @var{precision}, @var{skip}, and @var{arch} are\n\
1517 optional, and are interpreted as described for @code{fread}.\n\ 1517 optional, and are interpreted as described for @code{fread}.\n\
1518 \n\ 1518 \n\
1519 The behavior of @code{fwrite} is undefined if the values in @var{data}\n\ 1519 The behavior of @code{fwrite} is undefined if the values in @var{data}\n\
1520 are too large to fit in the specified precision.\n\ 1520 are too large to fit in the specified precision.\n\
1521 @end deftypefn\n\ 1521 @seealso{fread, fopen, fclose}\n\
1522 @seealso{fread, fopen, fclose}") 1522 @end deftypefn")
1523 { 1523 {
1524 octave_value retval = -1; 1524 octave_value retval = -1;
1525 1525
1526 int nargin = args.length (); 1526 int nargin = args.length ();
1527 1527
1558 @deftypefn {Built-in Function} {} feof (@var{fid})\n\ 1558 @deftypefn {Built-in Function} {} feof (@var{fid})\n\
1559 Return 1 if an end-of-file condition has been encountered for a given\n\ 1559 Return 1 if an end-of-file condition has been encountered for a given\n\
1560 file and 0 otherwise. Note that it will only return 1 if the end of the\n\ 1560 file and 0 otherwise. Note that it will only return 1 if the end of the\n\
1561 file has already been encountered, not if the next read operation will\n\ 1561 file has already been encountered, not if the next read operation will\n\
1562 result in an end-of-file condition.\n\ 1562 result in an end-of-file condition.\n\
1563 @end deftypefn\n\ 1563 @seealso{fread, fopen, fclose}\n\
1564 @seealso{fread, fopen, fclose}") 1564 @end deftypefn")
1565 { 1565 {
1566 octave_value retval = -1; 1566 octave_value retval = -1;
1567 1567
1568 int nargin = args.length (); 1568 int nargin = args.length ();
1569 1569
1727 If @var{dir} is also omitted, the default directory for temporary files\n\ 1727 If @var{dir} is also omitted, the default directory for temporary files\n\
1728 is used. If @var{dir} is provided, it must exist, otherwise the default\n\ 1728 is used. If @var{dir} is provided, it must exist, otherwise the default\n\
1729 directory for temporary files is used. Since the named file is not\n\ 1729 directory for temporary files is used. Since the named file is not\n\
1730 opened, by @code{tmpnam}, it is possible (though relatively unlikely)\n\ 1730 opened, by @code{tmpnam}, it is possible (though relatively unlikely)\n\
1731 that it will not be available by the time your program attempts to open it.\n\ 1731 that it will not be available by the time your program attempts to open it.\n\
1732 @end deftypefn\n\ 1732 @seealso{tmpfile, mkstemp, P_tmpdir}\n\
1733 @seealso{tmpfile, mkstemp, P_tmpdir}") 1733 @end deftypefn")
1734 { 1734 {
1735 octave_value retval; 1735 octave_value retval;
1736 1736
1737 int len = args.length (); 1737 int len = args.length ();
1738 1738
1770 exits.\n\ 1770 exits.\n\
1771 \n\ 1771 \n\
1772 If successful, @var{fid} is a valid file ID and @var{msg} is an empty\n\ 1772 If successful, @var{fid} is a valid file ID and @var{msg} is an empty\n\
1773 string. Otherwise, @var{fid} is -1 and @var{msg} contains a\n\ 1773 string. Otherwise, @var{fid} is -1 and @var{msg} contains a\n\
1774 system-dependent error message.\n\ 1774 system-dependent error message.\n\
1775 @end deftypefn\n\ 1775 @seealso{tmpnam, mkstemp, P_tmpdir}\n\
1776 @seealso{tmpnam, mkstemp, P_tmpdir}") 1776 @end deftypefn")
1777 { 1777 {
1778 octave_value_list retval; 1778 octave_value_list retval;
1779 1779
1780 retval(1) = std::string (); 1780 retval(1) = std::string ();
1781 retval(0) = -1; 1781 retval(0) = -1;
1830 \n\ 1830 \n\
1831 If successful, @var{fid} is a valid file ID, @var{name} is the name of\n\ 1831 If successful, @var{fid} is a valid file ID, @var{name} is the name of\n\
1832 the file, and and @var{msg} is an empty string. Otherwise, @var{fid}\n\ 1832 the file, and and @var{msg} is an empty string. Otherwise, @var{fid}\n\
1833 is -1, @var{name} is empty, and @var{msg} contains a system-dependent\n\ 1833 is -1, @var{name} is empty, and @var{msg} contains a system-dependent\n\
1834 error message.\n\ 1834 error message.\n\
1835 @end deftypefn\n\ 1835 @seealso{tmpfile, tmpnam, P_tmpdir}\n\
1836 @seealso{tmpfile, tmpnam, P_tmpdir}") 1836 @end deftypefn")
1837 { 1837 {
1838 octave_value_list retval; 1838 octave_value_list retval;
1839 1839
1840 retval(2) = std::string (); 1840 retval(2) = std::string ();
1841 retval(1) = std::string (); 1841 retval(1) = std::string ();