50 #include <sys/types.h>
119 tmp_files.push (file);
125 while (! tmp_files.empty ())
127 std::string filename = tmp_files.top ();
129 gnulib::unlink (filename.c_str ());
146 size_t pos = mode.find (
'W');
148 if (pos != std::string::npos)
151 "fopen: treating mode \"W\" as equivalent to \"w\"");
155 pos = mode.find (
'R');
157 if (pos != std::string::npos)
160 "fopen: treating mode \"R\" as equivalent to \"r\"");
164 pos = mode.find (
'A');
166 if (pos != std::string::npos)
169 "fopen: treating mode \"A\" as equivalent to \"a\"");
173 pos = mode.find (
'z');
175 if (pos != std::string::npos)
177 #if defined (HAVE_ZLIB)
181 error (
"this version of Octave does not support gzipped files");
190 size_t bpos = mode.find (
'b');
191 size_t tpos = mode.find (
't');
193 if (bpos == std::string::npos && tpos == std::string::npos)
199 static std::ios::openmode
202 std::ios::openmode retval = std::ios::in;
207 retval = std::ios::in;
208 else if (mode ==
"wt")
209 retval = std::ios::out | std::ios::trunc;
210 else if (mode ==
"at")
211 retval = std::ios::out | std::ios::app;
212 else if (mode ==
"r+t" || mode ==
"rt+")
213 retval = std::ios::in | std::ios::out;
214 else if (mode ==
"w+t" || mode ==
"wt+")
215 retval = std::ios::in | std::ios::out | std::ios::trunc;
216 else if (mode ==
"a+t" || mode ==
"at+")
217 retval = std::ios::in | std::ios::out | std::ios::app;
218 else if (mode ==
"rb" || mode ==
"r")
219 retval = std::ios::in | std::ios::binary;
220 else if (mode ==
"wb" || mode ==
"w")
221 retval = std::ios::out | std::ios::trunc | std::ios::binary;
222 else if (mode ==
"ab" || mode ==
"a")
223 retval = std::ios::out | std::ios::app | std::ios::binary;
224 else if (mode ==
"r+b" || mode ==
"rb+" || mode ==
"r+")
225 retval = std::ios::in | std::ios::out | std::ios::binary;
226 else if (mode ==
"w+b" || mode ==
"wb+" || mode ==
"w+")
227 retval = (std::ios::in | std::ios::out | std::ios::trunc
229 else if (mode ==
"a+b" || mode ==
"ab+" || mode ==
"a+")
230 retval = (std::ios::in | std::ios::out | std::ios::app
233 ::error (
"invalid mode specified");
239 DEFUN (fclose, args, ,
241 @deftypefn {Built-in Function} {} fclose (@var{fid})\n\
242 @deftypefnx {Built-in Function} {} fclose (\"all\")\n\
243 @deftypefnx {Built-in Function} {@var{status} =} fclose (\"all\")\n\
244 Close the file specified by the file descriptor @var{fid}.\n\
246 If successful, @code{fclose} returns 0, otherwise, it returns -1. The\n\
247 second form of the @code{fclose} call closes all open files except\n\
248 @code{stdout}, @code{stderr}, and @code{stdin}.\n\
250 Programming Note: When using @qcode{\"all\"} the file descriptors associated\n\
251 with gnuplot will also be closed. This will prevent further plotting with\n\
252 gnuplot until Octave is closed and restarted.\n\
253 @seealso{fopen, fflush, freport}\n\
258 int nargin = args.
length ();
268 DEFUN (fclear, args, ,
270 @deftypefn {Built-in Function} {} fclear (@var{fid})\n\
271 Clear the stream state for the file specified by the file descriptor\n\
273 @seealso{ferror, fopen}\n\
278 int nargin = args.
length ();
295 DEFUN (fflush, args, ,
297 @deftypefn {Built-in Function} {} fflush (@var{fid})\n\
298 Flush output to file descriptor @var{fid}.\n\
300 @code{fflush} returns 0 on success and an OS dependent error value\n\
301 (@minus{}1 on Unix) on error.\n\
303 Programming Note: Flushing is useful for ensuring that all pending output\n\
304 makes it to the screen before some other event occurs. For example, it is\n\
305 always a good idea to flush the standard output stream before calling\n\
307 @seealso{fopen, fclose}\n\
312 int nargin = args.
length ();
331 retval = os.
flush ();
340 DEFUN (fgetl, args, ,
342 @deftypefn {Built-in Function} {@var{str} =} fgetl (@var{fid})\n\
343 @deftypefnx {Built-in Function} {@var{str} =} fgetl (@var{fid}, @var{len})\n\
344 Read characters from a file, stopping after a newline, or EOF,\n\
345 or @var{len} characters have been read.\n\
347 The characters read, excluding the possible trailing newline, are returned\n\
350 If @var{len} is omitted, @code{fgetl} reads until the next newline character.\n\
352 If there are no more characters to read, @code{fgetl} returns @minus{}1.\n\
354 To read a line and return the terminating newline see @code{fgets}.\n\
355 @seealso{fgets, fscanf, fread, fopen}\n\
358 static std::string who =
"fgetl";
365 int nargin = args.
length ();
367 if (nargin == 1 || nargin == 2)
377 std::string tmp = os.
getl (len_arg, err, who);
381 retval(1) = tmp.
length ();
392 DEFUN (fgets, args, ,
394 @deftypefn {Built-in Function} {@var{str} =} fgets (@var{fid})\n\
395 @deftypefnx {Built-in Function} {@var{str} =} fgets (@var{fid}, @var{len})\n\
396 Read characters from a file, stopping after a newline, or EOF,\n\
397 or @var{len} characters have been read.\n\
399 The characters read, including the possible trailing newline, are returned\n\
402 If @var{len} is omitted, @code{fgets} reads until the next newline character.\n\
404 If there are no more characters to read, @code{fgets} returns @minus{}1.\n\
406 To read a line and discard the terminating newline see @code{fgetl}.\n\
407 @seealso{fputs, fgetl, fscanf, fread, fopen}\n\
410 static std::string who =
"fgets";
417 int nargin = args.
length ();
419 if (nargin == 1 || nargin == 2)
429 std::string tmp = os.
gets (len_arg, err, who);
433 retval(1) = tmp.
length ();
444 DEFUN (fskipl, args, ,
446 @deftypefn {Built-in Function} {@var{nlines} =} fskipl (@var{fid})\n\
447 @deftypefnx {Built-in Function} {@var{nlines} =} fskipl (@var{fid}, @var{count})\n\
448 @deftypefnx {Built-in Function} {@var{nlines} =} fskipl (@var{fid}, Inf)\n\
449 Read and skip @var{count} lines from the file specified by the file\n\
450 descriptor @var{fid}.\n\
452 @code{fskipl} discards characters until an end-of-line is encountered exactly\n\
453 @var{count}-times, or until the end-of-file marker is found.\n\
455 If @var{count} is omitted, it defaults to 1. @var{count} may also be\n\
456 @code{Inf}, in which case lines are skipped until the end of the file.\n\
457 This form is suitable for counting the number of lines in a file.\n\
459 Returns the number of lines skipped (end-of-line sequences encountered).\n\
460 @seealso{fgetl, fgets, fscanf, fopen}\n\
463 static std::string who =
"fskipl";
467 int nargin = args.
length ();
469 if (nargin == 1 || nargin == 2)
479 off_t tmp = os.
skipl (count_arg, err, who);
494 const std::string& arch,
int& fid)
500 std::string mode = mode_arg;
501 bool use_zlib =
false;
517 if (! (md & std::ios::out))
522 #if defined (HAVE_ZLIB)
525 FILE *
fptr = gnulib::fopen (fname.c_str (), mode.c_str ());
527 int fd = fileno (fptr);
529 gzFile gzf = ::gzdopen (fd, mode.c_str ());
535 retval.
error (gnulib::strerror (errno));
540 FILE *
fptr = gnulib::fopen (fname.c_str (), mode.c_str ());
546 retval.error (gnulib::strerror (errno));
579 ::error (
"%s: architecture type must be a string", fcn);
582 ::error (
"%s: file mode must be a string", fcn);
585 ::error (
"%s: file name must be a string", fcn);
590 DEFUN (fopen, args, nargout,
592 @deftypefn {Built-in Function} {@var{fid} =} fopen (@var{name})\n\
593 @deftypefnx {Built-in Function} {@var{fid} =} fopen (@var{name}, @var{mode})\n\
594 @deftypefnx {Built-in Function} {@var{fid} =} fopen (@var{name}, @var{mode}, @var{arch})\n\
595 @deftypefnx {Built-in Function} {[@var{fid}, @var{msg}] =} fopen (@dots{})\n\
596 @deftypefnx {Built-in Function} {@var{fid_list} =} fopen (\"all\")\n\
597 @deftypefnx {Built-in Function} {[@var{file}, @var{mode}, @var{arch}] =} fopen (@var{fid})\n\
598 Open a file for low-level I/O or query open files and file descriptors.\n\
600 The first form of the @code{fopen} function opens the named file with\n\
601 the specified mode (read-write, read-only, etc.) and architecture\n\
602 interpretation (IEEE big endian, IEEE little endian, etc.), and returns\n\
603 an integer value that may be used to refer to the file later. If an\n\
604 error occurs, @var{fid} is set to @minus{}1 and @var{msg} contains the\n\
605 corresponding system error message. The @var{mode} is a one or two\n\
606 character string that specifies whether the file is to be opened for\n\
607 reading, writing, or both.\n\
609 The second form of the @code{fopen} function returns a vector of file ids\n\
610 corresponding to all the currently open files, excluding the\n\
611 @code{stdin}, @code{stdout}, and @code{stderr} streams.\n\
613 The third form of the @code{fopen} function returns information about the\n\
614 open file given its file id.\n\
619 myfile = fopen (\"splat.dat\", \"r\", \"ieee-le\");\n\
623 opens the file @file{splat.dat} for reading. If necessary, binary\n\
624 numeric values will be read assuming they are stored in IEEE format with\n\
625 the least significant bit first, and then converted to the native\n\
628 Opening a file that is already open simply opens it again and returns a\n\
629 separate file id. It is not an error to open a file several times,\n\
630 though writing to the same file through several different file ids may\n\
631 produce unexpected results.\n\
633 The possible values @samp{mode} may have are\n\
636 @item @samp{r} (default)\n\
637 Open a file for reading.\n\
640 Open a file for writing. The previous contents are discarded.\n\
643 Open or create a file for writing at the end of the file.\n\
646 Open an existing file for reading and writing.\n\
649 Open a file for reading or writing. The previous contents are\n\
653 Open or create a file for reading or writing at the end of the\n\
657 Append a @qcode{\"t\"} to the mode string to open the file in text mode or a\n\
658 @qcode{\"b\"} to open in binary mode. On Windows and Macintosh systems, text\n\
659 mode reading and writing automatically converts linefeeds to the\n\
660 appropriate line end character for the system (carriage-return linefeed\n\
661 on Windows, carriage-return on Macintosh). The default when no mode is\n\
662 specified is binary mode.\n\
664 Additionally, you may append a @qcode{\"z\"} to the mode string to open a\n\
665 gzipped file for reading or writing. For this to be successful, you\n\
666 must also open the file in binary mode.\n\
668 The parameter @var{arch} is a string specifying the default data format\n\
669 for the file. Valid values for @var{arch} are:\n\
672 @item native (default)\n\
673 The format of the current machine.\n\
676 IEEE big endian format.\n\
679 IEEE little endian format.\n\
683 however, conversions are currently only supported for @samp{native}\n\
684 @samp{ieee-be}, and @samp{ieee-le} formats.\n\
686 When opening a new file that does not yet exist, permissions will be set to\n\
687 @code{0666 - @var{umask}}.\n\
688 @seealso{fclose, fgets, fgetl, fscanf, fread, fputs, fdisp, fprintf, fwrite, fskipl, fseek, frewind, ftell, feof, ferror, fclear, fflush, freport, umask}\n\
695 int nargin = args.
length ();
699 if (args(0).is_string ())
706 if (nargout < 2 && args(0).string_value () ==
"all")
724 if (nargin > 0 && nargin < 4)
743 int error_number = 0;
745 retval(1) = os.
error (
false, error_number);
755 DEFUN (freport, args, ,
757 @deftypefn {Built-in Function} {} freport ()\n\
758 Print a list of which files have been opened, and whether they are open\n\
759 for reading, writing, or both.\n\
767 @print{} number mode arch name\n\
768 @print{} ------ ---- ---- ----\n\
769 @print{} 0 r ieee-le stdin\n\
770 @print{} 1 w ieee-le stdout\n\
771 @print{} 2 w ieee-le stderr\n\
772 @print{} 3 r ieee-le myfile\n\
775 @seealso{fopen, fclose, is_valid_file_id}\n\
780 int nargin = args.
length ();
783 warning (
"freport: ignoring extra arguments");
790 DEFUN (frewind, args, nargout,
792 @deftypefn {Built-in Function} {} frewind (@var{fid})\n\
793 @deftypefnx {Built-in Function} {@var{status} =} frewind (@var{fid})\n\
794 Move the file pointer to the beginning of the file specified by file\n\
795 descriptor @var{fid}.\n\
797 @code{frewind} returns 0 for success, and -1 if an error is encountered. It\n\
798 is equivalent to @code{fseek (@var{fid}, 0, SEEK_SET)}.\n\
799 @seealso{fseek, ftell, fopen}\n\
806 int nargin = args.
length ();
824 DEFUN (fseek, args, ,
826 @deftypefn {Built-in Function} {} fseek (@var{fid}, @var{offset})\n\
827 @deftypefnx {Built-in Function} {} fseek (@var{fid}, @var{offset}, @var{origin})\n\
828 @deftypefnx {Built-in Function} {@var{status} =} fseek (@dots{})\n\
829 Set the file pointer to the location @var{offset} within the file @var{fid}.\n\
831 The pointer is positioned @var{offset} characters from the @var{origin},\n\
832 which may be one of the predefined variables @w{@code{SEEK_CUR}} (current\n\
833 position), @w{@code{SEEK_SET}} (beginning), or @w{@code{SEEK_END}} (end of\n\
834 file) or strings @qcode{\"cof\"}, @qcode{\"bof\"} or @qcode{\"eof\"}. If\n\
835 @var{origin} is omitted, @w{@code{SEEK_SET}} is assumed. @var{offset} may\n\
836 be positive, negative, or zero but not all combinations of @var{origin} and\n\
837 @var{offset} can be realized.\n\
839 @code{fseek} returns 0 on success and -1 on error.\n\
840 @seealso{fskipl, frewind, ftell, fopen}\n\
845 int nargin = args.
length ();
847 if (nargin == 2 || nargin == 3)
856 retval = os.
seek (args(1), origin_arg);
865 DEFUN (ftell, args, ,
867 @deftypefn {Built-in Function} {@var{pos} =} ftell (@var{fid})\n\
868 Return the position of the file pointer as the number of characters from the\n\
869 beginning of the file specified by file descriptor @var{fid}.\n\
870 @seealso{fseek, frewind, feof, fopen}\n\
875 int nargin = args.
length ();
890 DEFUN (fprintf, args, nargout,
892 @deftypefn {Built-in Function} {} fprintf (@var{fid}, @var{template}, @dots{})\n\
893 @deftypefnx {Built-in Function} {} fprintf (@var{template}, @dots{})\n\
894 @deftypefnx {Built-in Function} {@var{numbytes} =} fprintf (@dots{})\n\
895 This function is equivalent to @code{printf}, except that the output is\n\
896 written to the file descriptor @var{fid} instead of @code{stdout}.\n\
898 If @var{fid} is omitted, the output is written to @code{stdout} making the\n\
899 function exactly equivalent to @code{printf}.\n\
901 The optional output returns the number of bytes written to the file.\n\
903 Implementation Note: For compatibility with @sc{matlab}, escape sequences in\n\
904 the template string (e.g., @qcode{\"@xbackslashchar{}n\"} => newline) are\n\
905 expanded even when the template string is defined with single quotes.\n\
906 @seealso{fputs, fdisp, fwrite, fscanf, printf, sprintf, fopen}\n\
909 static std::string who =
"fprintf";
915 int nargin = args.
length ();
917 if (nargin > 1 || (nargin > 0 && args(0).is_string ()))
922 if (args(0).is_string ())
934 if (args(fmt_n).is_string ())
938 if (nargin > 1 + fmt_n)
942 for (
int i = fmt_n + 1; i < nargin; i++)
943 tmp_args(i-fmt_n-1) = args(i);
946 result = os.
printf (args(fmt_n), tmp_args, who);
949 ::error (
"%s: format TEMPLATE must be a string", who.c_str ());
961 DEFUN (printf, args, nargout,
963 @deftypefn {Built-in Function} {} printf (@var{template}, @dots{})\n\
964 Print optional arguments under the control of the template string\n\
965 @var{template} to the stream @code{stdout} and return the number of\n\
966 characters printed.\n\
967 @ifclear OCTAVE_MANUAL\n\
969 See the Formatted Output section of the GNU Octave manual for a\n\
970 complete description of the syntax of the template string.\n\
973 Implementation Note: For compatibility with @sc{matlab}, escape sequences in\n\
974 the template string (e.g., @qcode{\"@xbackslashchar{}n\"} => newline) are\n\
975 expanded even when the template string is defined with single quotes.\n\
976 @seealso{fprintf, sprintf, scanf}\n\
979 static std::string who =
"printf";
985 int nargin = args.
length ();
989 if (args(0).is_string ())
997 for (
int i = 1; i < nargin; i++)
998 tmp_args(i-1) = args(i);
1001 result = stdout_stream.
printf (args(0), tmp_args, who);
1004 ::error (
"%s: format TEMPLATE must be a string", who.c_str ());
1015 DEFUN (fputs, args, ,
1017 @deftypefn {Built-in Function} {} fputs (@var{fid}, @var{string})\n\
1018 @deftypefnx {Built-in Function} {@var{status} =} fputs (@var{fid}, @var{string})\n\
1019 Write the string @var{string} to the file with file descriptor @var{fid}.\n\
1021 The string is written to the file with no additional formatting. Use\n\
1022 @code{fdisp} instead to automatically append a newline character appropriate\n\
1023 for the local machine.\n\
1025 Return a non-negative number on success or EOF on error.\n\
1026 @seealso{fdisp, fprintf, fwrite, fopen}\n\
1029 static std::string who =
"fputs";
1033 int nargin = args.
length ();
1040 retval = os.
puts (args(1), who);
1048 DEFUN (puts, args, ,
1050 @deftypefn {Built-in Function} {} puts (@var{string})\n\
1051 @deftypefnx {Built-in Function} {@var{status} =} puts (@var{string})\n\
1052 Write a string to the standard output with no formatting.\n\
1054 The string is written verbatim to the standard output. Use @code{disp} to\n\
1055 automatically append a newline character appropriate for the local machine.\n\
1057 Return a non-negative number on success and EOF on error.\n\
1058 @seealso{fputs, disp}\n\
1061 static std::string who =
"puts";
1065 if (args.length () == 1)
1066 retval = stdout_stream.
puts (args(0), who);
1073 DEFUN (sprintf, args, ,
1075 @deftypefn {Built-in Function} {} sprintf (@var{template}, @dots{})\n\
1076 This is like @code{printf}, except that the output is returned as a\n\
1079 Unlike the C library function, which requires you to provide a suitably\n\
1080 sized string as an argument, Octave's @code{sprintf} function returns the\n\
1081 string, automatically sized to hold all of the items converted.\n\
1083 Implementation Note: For compatibility with @sc{matlab}, escape sequences in\n\
1084 the template string (e.g., @qcode{\"@xbackslashchar{}n\"} => newline) are\n\
1085 expanded even when the template string is defined with single quotes.\n\
1086 @seealso{printf, fprintf, sscanf}\n\
1089 static std::string who =
"sprintf";
1093 int nargin = args.
length ();
1098 retval(1) =
"unknown error";
1117 for (
int i = 1; i < nargin; i++)
1118 tmp_args(i-1) = args(i);
1121 retval(2) = os.
printf (fmt_arg, tmp_args, who);
1122 retval(1) = os.
error ();
1124 std::string result = ostr->
str ();
1127 retval(0) = (result.empty ()
1132 ::error (
"%s: format TEMPLATE must be a string", who.c_str ());
1135 ::error (
"%s: unable to create output buffer", who.c_str ());
1143 DEFUN (fscanf, args, ,
1145 @deftypefn {Built-in Function} {[@var{val}, @var{count}, @var{errmsg}] =} fscanf (@var{fid}, @var{template}, @var{size})\n\
1146 @deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}, @var{errmsg}] =} fscanf (@var{fid}, @var{template}, \"C\")\n\
1147 In the first form, read from @var{fid} according to @var{template},\n\
1148 returning the result in the matrix @var{val}.\n\
1150 The optional argument @var{size} specifies the amount of data to read\n\
1151 and may be one of\n\
1155 Read as much as possible, returning a column vector.\n\
1158 Read up to @var{nr} elements, returning a column vector.\n\
1160 @item [@var{nr}, Inf]\n\
1161 Read as much as possible, returning a matrix with @var{nr} rows. If the\n\
1162 number of elements read is not an exact multiple of @var{nr}, the last\n\
1163 column is padded with zeros.\n\
1165 @item [@var{nr}, @var{nc}]\n\
1166 Read up to @code{@var{nr} * @var{nc}} elements, returning a matrix with\n\
1167 @var{nr} rows. If the number of elements read is not an exact multiple\n\
1168 of @var{nr}, the last column is padded with zeros.\n\
1172 If @var{size} is omitted, a value of @code{Inf} is assumed.\n\
1174 A string is returned if @var{template} specifies only character conversions.\n\
1176 The number of items successfully read is returned in @var{count}.\n\
1178 If an error occurs, @var{errmsg} contains a system-dependent error message.\n\
1180 In the second form, read from @var{fid} according to @var{template},\n\
1181 with each conversion specifier in @var{template} corresponding to a\n\
1182 single scalar return value. This form is more ``C-like'', and also\n\
1183 compatible with previous versions of Octave. The number of successful\n\
1184 conversions is returned in @var{count}\n\
1185 @ifclear OCTAVE_MANUAL\n\
1187 See the Formatted Input section of the GNU Octave manual for a\n\
1188 complete description of the syntax of the template string.\n\
1190 @seealso{fgets, fgetl, fread, scanf, sscanf, fopen}\n\
1193 static std::string who =
"fscanf";
1197 int nargin = args.
length ();
1199 if (nargin == 3 && args(2).is_string ())
1205 if (args(1).is_string ())
1206 retval = os.
oscanf (args(1), who);
1208 ::error (
"%s: format TEMPLATE must be a string", who.c_str ());
1213 retval(2) =
"unknown error";
1217 if (nargin == 2 || nargin == 3)
1223 if (args(1).is_string ())
1228 ? args(2).vector_value ()
1238 retval(2) = os.
error ();
1245 ::error (
"%s: format must be a string", who.c_str ());
1267 ::error (
"sscanf: argument STRING must be a string");
1272 DEFUN (sscanf, args, ,
1274 @deftypefn {Built-in Function} {[@var{val}, @var{count}, @var{errmsg}, @var{pos}] =} sscanf (@var{string}, @var{template}, @var{size})\n\
1275 @deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}, @var{errmsg}] =} sscanf (@var{string}, @var{template}, \"C\")\n\
1276 This is like @code{fscanf}, except that the characters are taken from the\n\
1277 string @var{string} instead of from a stream.\n\
1279 Reaching the end of the string is treated as an end-of-file condition. In\n\
1280 addition to the values returned by @code{fscanf}, the index of the next\n\
1281 character to be read is returned in @var{pos}.\n\
1282 @seealso{fscanf, scanf, sprintf}\n\
1285 static std::string who =
"sscanf";
1289 int nargin = args.
length ();
1291 if (nargin == 3 && args(2).is_string ())
1301 if (args(1).is_string ())
1302 retval = os.
oscanf (args(1), who);
1304 ::error (
"%s: format TEMPLATE must be a string", who.c_str ());
1307 ::error (
"%s: unable to create temporary input buffer",
1311 ::error (
"%s: argument STRING must be a string", who.c_str ());
1315 if (nargin == 2 || nargin == 3)
1318 retval(2) =
"unknown error";
1330 if (args(1).is_string ())
1335 ? args(2).vector_value ()
1346 std::string errmsg = os.
error ();
1349 = (os.
eof () ? data.length () : os.
tell ()) + 1;
1356 ::error (
"%s: format TEMPLATE must be a string",
1360 ::error (
"%s: unable to create temporary input buffer",
1371 DEFUN (scanf, args, nargout,
1373 @deftypefn {Built-in Function} {[@var{val}, @var{count}, @var{errmsg}] =} scanf (@var{template}, @var{size})\n\
1374 @deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}, @var{errmsg}]] =} scanf (@var{template}, \"C\")\n\
1375 This is equivalent to calling @code{fscanf} with @var{fid} = @code{stdin}.\n\
1377 It is currently not useful to call @code{scanf} in interactive programs.\n\
1378 @seealso{fscanf, sscanf, printf}\n\
1381 int nargin = args.length ();
1386 for (
int i = 0; i < nargin; i++)
1387 tmp_args(i+1) = args(i);
1389 return Ffscanf (tmp_args, nargout);
1414 input_type, output_type);
1430 retval = os.
read (size, block_size, input_type,
1431 output_type, skip, flt_fmt, count);
1434 ::error (
"fread: ARCH architecture type must be a string");
1437 ::error (
"fread: SKIP must be an integer");
1440 ::error (
"fread: invalid PRECISION specified");
1443 ::error (
"fread: PRECISION must be a string");
1446 ::error (
"fread: invalid SIZE specified");
1451 DEFUN (fread, args, ,
1453 @deftypefn {Built-in Function} {@var{val} =} fread (@var{fid})\n\
1454 @deftypefnx {Built-in Function} {@var{val} =} fread (@var{fid}, @var{size})\n\
1455 @deftypefnx {Built-in Function} {@var{val} =} fread (@var{fid}, @var{size}, @var{precision})\n\
1456 @deftypefnx {Built-in Function} {@var{val} =} fread (@var{fid}, @var{size}, @var{precision}, @var{skip})\n\
1457 @deftypefnx {Built-in Function} {@var{val} =} fread (@var{fid}, @var{size}, @var{precision}, @var{skip}, @var{arch})\n\
1458 @deftypefnx {Built-in Function} {[@var{val}, @var{count}] =} fread (@dots{})\n\
1459 Read binary data from the file specified by the file descriptor @var{fid}.\n\
1461 The optional argument @var{size} specifies the amount of data to read\n\
1462 and may be one of\n\
1466 Read as much as possible, returning a column vector.\n\
1469 Read up to @var{nr} elements, returning a column vector.\n\
1471 @item [@var{nr}, Inf]\n\
1472 Read as much as possible, returning a matrix with @var{nr} rows. If the\n\
1473 number of elements read is not an exact multiple of @var{nr}, the last\n\
1474 column is padded with zeros.\n\
1476 @item [@var{nr}, @var{nc}]\n\
1477 Read up to @code{@var{nr} * @var{nc}} elements, returning a matrix with\n\
1478 @var{nr} rows. If the number of elements read is not an exact multiple\n\
1479 of @var{nr}, the last column is padded with zeros.\n\
1483 If @var{size} is omitted, a value of @code{Inf} is assumed.\n\
1485 The optional argument @var{precision} is a string specifying the type of\n\
1486 data to read and may be one of\n\
1489 @item @qcode{\"schar\"}\n\
1490 @itemx @qcode{\"signed char\"}\n\
1491 Signed character.\n\
1493 @item @qcode{\"uchar\"}\n\
1494 @itemx @qcode{\"unsigned char\"}\n\
1495 Unsigned character.\n\
1497 @item @qcode{\"int8\"}\n\
1498 @itemx @qcode{\"integer*1\"}\n\
1500 8-bit signed integer.\n\
1502 @item @qcode{\"int16\"}\n\
1503 @itemx @qcode{\"integer*2\"}\n\
1504 16-bit signed integer.\n\
1506 @item @qcode{\"int32\"}\n\
1507 @itemx @qcode{\"integer*4\"}\n\
1508 32-bit signed integer.\n\
1510 @item @qcode{\"int64\"}\n\
1511 @itemx @qcode{\"integer*8\"}\n\
1512 64-bit signed integer.\n\
1514 @item @qcode{\"uint8\"}\n\
1515 8-bit unsigned integer.\n\
1517 @item @qcode{\"uint16\"}\n\
1518 16-bit unsigned integer.\n\
1520 @item @qcode{\"uint32\"}\n\
1521 32-bit unsigned integer.\n\
1523 @item @qcode{\"uint64\"}\n\
1524 64-bit unsigned integer.\n\
1526 @item @qcode{\"single\"}\n\
1527 @itemx @qcode{\"float32\"}\n\
1528 @itemx @qcode{\"real*4\"}\n\
1529 32-bit floating point number.\n\
1531 @item @qcode{\"double\"}\n\
1532 @itemx @qcode{\"float64\"}\n\
1533 @itemx @qcode{\"real*8\"}\n\
1534 64-bit floating point number.\n\
1536 @item @qcode{\"char\"}\n\
1537 @itemx @qcode{\"char*1\"}\n\
1538 Single character.\n\
1540 @item @qcode{\"short\"}\n\
1541 Short integer (size is platform dependent).\n\
1543 @item @qcode{\"int\"}\n\
1544 Integer (size is platform dependent).\n\
1546 @item @qcode{\"long\"}\n\
1547 Long integer (size is platform dependent).\n\
1549 @item @qcode{\"ushort\"}\n\
1550 @itemx @qcode{\"unsigned short\"}\n\
1551 Unsigned short integer (size is platform dependent).\n\
1553 @item @qcode{\"uint\"}\n\
1554 @itemx @qcode{\"unsigned int\"}\n\
1555 Unsigned integer (size is platform dependent).\n\
1557 @item @qcode{\"ulong\"}\n\
1558 @itemx @qcode{\"unsigned long\"}\n\
1559 Unsigned long integer (size is platform dependent).\n\
1561 @item @qcode{\"float\"}\n\
1562 Single precision floating point number (size is platform dependent).\n\
1566 The default precision is @qcode{\"uchar\"}.\n\
1568 The @var{precision} argument may also specify an optional repeat\n\
1569 count. For example, @samp{32*single} causes @code{fread} to read\n\
1570 a block of 32 single precision floating point numbers. Reading in\n\
1571 blocks is useful in combination with the @var{skip} argument.\n\
1573 The @var{precision} argument may also specify a type conversion.\n\
1574 For example, @samp{int16=>int32} causes @code{fread} to read 16-bit\n\
1575 integer values and return an array of 32-bit integer values. By\n\
1576 default, @code{fread} returns a double precision array. The special\n\
1577 form @samp{*TYPE} is shorthand for @samp{TYPE=>TYPE}.\n\
1579 The conversion and repeat counts may be combined. For example, the\n\
1580 specification @samp{32*single=>single} causes @code{fread} to read\n\
1581 blocks of single precision floating point values and return an array\n\
1582 of single precision values instead of the default array of double\n\
1583 precision values.\n\
1585 The optional argument @var{skip} specifies the number of bytes to skip\n\
1586 after each element (or block of elements) is read. If it is not\n\
1587 specified, a value of 0 is assumed. If the final block read is not\n\
1588 complete, the final skip is omitted. For example,\n\
1591 fread (f, 10, \"3*single=>single\", 8)\n\
1595 will omit the final 8-byte skip because the last read will not be\n\
1596 a complete block of 3 values.\n\
1598 The optional argument @var{arch} is a string specifying the data format\n\
1599 for the file. Valid values are\n\
1602 @item @qcode{\"native\"}\n\
1603 The format of the current machine.\n\
1605 @item @qcode{\"ieee-be\"}\n\
1608 @item @qcode{\"ieee-le\"}\n\
1609 IEEE little endian.\n\
1612 The output argument @var{val} contains the data read from the file.\n\
1613 The optional return value @var{count} contains the number of elements read.\n\
1614 @seealso{fwrite, fgets, fgetl, fscanf, fopen}\n\
1619 int nargin = args.
length ();
1621 if (nargin > 0 && nargin < 6)
1637 if (nargin > idx && ! args(idx).is_string ())
1698 retval = os.
write (data, block_size, output_type,
1702 ::error (
"fwrite: ARCH architecture type must be a string");
1705 ::error (
"fwrite: SKIP must be an integer");
1708 ::error (
"fwrite: invalid PRECISION specified");
1711 ::error (
"fwrite: PRECISION must be a string");
1716 DEFUN (fwrite, args, ,
1718 @deftypefn {Built-in Function} {} fwrite (@var{fid}, @var{data})\n\
1719 @deftypefnx {Built-in Function} {} fwrite (@var{fid}, @var{data}, @var{precision})\n\
1720 @deftypefnx {Built-in Function} {} fwrite (@var{fid}, @var{data}, @var{precision}, @var{skip})\n\
1721 @deftypefnx {Built-in Function} {} fwrite (@var{fid}, @var{data}, @var{precision}, @var{skip}, @var{arch})\n\
1722 @deftypefnx {Built-in Function} {@var{count} =} fwrite (@dots{})\n\
1723 Write data in binary form to the file specified by the file descriptor\n\
1724 @var{fid}, returning the number of values @var{count} successfully written\n\
1727 The argument @var{data} is a matrix of values that are to be written to\n\
1728 the file. The values are extracted in column-major order.\n\
1730 The remaining arguments @var{precision}, @var{skip}, and @var{arch} are\n\
1731 optional, and are interpreted as described for @code{fread}.\n\
1733 The behavior of @code{fwrite} is undefined if the values in @var{data}\n\
1734 are too large to fit in the specified precision.\n\
1735 @seealso{fread, fputs, fprintf, fopen}\n\
1740 int nargin = args.
length ();
1742 if (nargin > 1 && nargin < 6)
1770 double status =
do_fwrite (os, data, prec, skip, arch);
1783 @deftypefn {Built-in Function} {@var{status} =} feof (@var{fid})\n\
1784 Return 1 if an end-of-file condition has been encountered for the file\n\
1785 specified by file descriptor @var{fid} and 0 otherwise.\n\
1787 Note that @code{feof} will only return 1 if the end of the file has already\n\
1788 been encountered, not if the next read operation will result in an\n\
1789 end-of-file condition.\n\
1790 @seealso{fread, frewind, fseek, fclear, fopen}\n\
1795 int nargin = args.
length ();
1802 retval = os.
eof () ? 1.0 : 0.0;
1812 @deftypefn {Built-in Function} {@var{msg} =} ferror (@var{fid})\n\
1813 @deftypefnx {Built-in Function} {[@var{msg}, @var{err}] =} ferror (@var{fid})\n\
1814 @deftypefnx {Built-in Function} {[@var{dots}] =} ferror (@var{fid}, \"clear\")\n\
1815 Query the error status of the stream specified by file descriptor @var{fid}\n\
1817 If an error condition exists then return a string @var{msg} describing the\n\
1818 error. Otherwise, return an empty string @qcode{\"\"}.\n\
1820 The second input @qcode{\"clear\"} is optional. If supplied, the error\n\
1821 state on the stream will be cleared.\n\
1823 The optional second output is a numeric indication of the error status.\n\
1824 @var{err} is 1 if an error condition has been encountered and 0 otherwise.\n\
1826 Note that @code{ferror} indicates if an error has already occurred, not\n\
1827 whether the next operation will result in an error condition.\n\
1828 @seealso{fclear, fopen}\n\
1833 int nargin = args.
length ();
1835 if (nargin == 1 || nargin == 2)
1845 std::string opt = args(1).string_value ();
1848 clear = (opt ==
"clear");
1853 int error_number = 0;
1855 std::string error_message = os.
error (clear, error_number);
1857 retval(1) = error_number;
1858 retval(0) = error_message;
1869 @deftypefn {Built-in Function} {@var{fid} =} popen (@var{command}, @var{mode})\n\
1870 Start a process and create a pipe.\n\
1872 The name of the command to run is given by @var{command}. The argument\n\
1873 @var{mode} may be\n\
1876 @item @qcode{\"r\"}\n\
1877 The pipe will be connected to the standard output of the process, and\n\
1878 open for reading.\n\
1880 @item @qcode{\"w\"}\n\
1881 The pipe will be connected to the standard input of the process, and\n\
1882 open for writing.\n\
1885 The file identifier corresponding to the input or output stream of the\n\
1886 process is returned in @var{fid}.\n\
1892 fid = popen (\"ls -ltr / | tail -3\", \"r\");\n\
1893 while (ischar (s = fgets (fid)))\n\
1894 fputs (stdout, s);\n\
1897 @print{} drwxr-xr-x 33 root root 3072 Feb 15 13:28 etc\n\
1898 @print{} drwxr-xr-x 3 root root 1024 Feb 15 13:28 lib\n\
1899 @print{} drwxrwxrwt 15 root root 2048 Feb 17 14:53 tmp\n\
1907 int nargin = args.
length ();
1911 if (args(0).is_string ())
1913 std::string name = args(0).string_value ();
1915 if (args(1).is_string ())
1917 std::string mode = args(1).string_value ();
1925 else if (mode ==
"w")
1932 ::error (
"popen: invalid MODE specified");
1935 ::error (
"popen: MODE must be a string");
1938 ::error (
"popen: COMMAND must be a string");
1948 @deftypefn {Built-in Function} {} pclose (@var{fid})\n\
1949 Close a file identifier that was opened by @code{popen}.\n\
1951 The function @code{fclose} may also be used for the same purpose.\n\
1952 @seealso{fclose, popen}\n\
1957 int nargin = args.
length ();
1967 DEFUN (tempname, args, ,
1969 @deftypefn {Built-in Function} {@var{fname} =} tempname ()\n\
1970 @deftypefnx {Built-in Function} {@var{fname} =} tempname (@var{dir})\n\
1971 @deftypefnx {Built-in Function} {@var{fname} =} tempname (@var{dir}, @var{prefix})\n\
1972 Return a unique temporary file name as a string.\n\
1974 If @var{prefix} is omitted, a value of @qcode{\"oct-\"} is used.\n\
1976 If @var{dir} is also omitted, the default directory for temporary files\n\
1977 (@code{P_tmpdir}) is used. If @var{dir} is provided, it must exist,\n\
1978 otherwise the default directory for temporary files is used.\n\
1980 Programming Note: Because the named file is not opened by @code{tempname},\n\
1981 it is possible, though relatively unlikely, that it will not be available\n\
1982 by the time your program attempts to open it. If this is a concern,\n\
1983 see @code{tmpfile}.\n\
1984 @seealso{mkstemp, tempdir, P_tmpdir, tmpfile}\n\
1989 int len = args.
length ();
1996 if (args(0).is_string ())
1997 dir = args(0).string_value ();
1999 ::error (
"DIR must be a string");
2002 std::string pfx (
"oct-");
2005 if (args(1).is_string ())
2006 pfx = args(1).string_value ();
2008 ::error (
"PREFIX must be a string");
2067 DEFUN (tmpfile, args, ,
2069 @deftypefn {Built-in Function} {[@var{fid}, @var{msg}] =} tmpfile ()\n\
2070 Return the file ID corresponding to a new temporary file with a unique\n\
2073 The file is opened in binary read/write (@qcode{\"w+b\"}) mode and will be\n\
2074 deleted automatically when it is closed or when Octave exits.\n\
2076 If successful, @var{fid} is a valid file ID and @var{msg} is an empty\n\
2077 string. Otherwise, @var{fid} is -1 and @var{msg} contains a\n\
2078 system-dependent error message.\n\
2079 @seealso{tempname, mkstemp, tempdir, P_tmpdir}\n\
2084 retval(1) = std::string ();
2087 int nargin = args.
length ();
2091 FILE *fid = gnulib::tmpfile ();
2104 error (
"tmpfile: failed to create octave_stdiostream object");
2109 retval(1) = gnulib::strerror (errno);
2119 DEFUN (mkstemp, args, ,
2121 @deftypefn {Built-in Function} {[@var{fid}, @var{name}, @var{msg}] =} mkstemp (\"@var{template}\")\n\
2122 @deftypefnx {Built-in Function} {[@var{fid}, @var{name}, @var{msg}] =} mkstemp (\"@var{template}\", @var{delete})\n\
2123 Return the file descriptor @var{fid} corresponding to a new temporary file\n\
2124 with a unique name created from @var{template}.\n\
2126 The last six characters of @var{template} must be @qcode{\"XXXXXX\"} and\n\
2127 these are replaced with a string that makes the filename unique. The file\n\
2128 is then created with mode read/write and permissions that are system\n\
2129 dependent (on GNU/Linux systems, the permissions will be 0600 for versions of\n\
2130 glibc 2.0.7 and later). The file is opened in binary mode and with the\n\
2131 @w{@code{O_EXCL}} flag.\n\
2133 If the optional argument @var{delete} is supplied and is true, the file will\n\
2134 be deleted automatically when Octave exits.\n\
2136 If successful, @var{fid} is a valid file ID, @var{name} is the name of the\n\
2137 file, and @var{msg} is an empty string. Otherwise, @var{fid} is -1,\n\
2138 @var{name} is empty, and @var{msg} contains a system-dependent error message.\n\
2139 @seealso{tempname, tempdir, P_tmpdir, tmpfile, fopen}\n\
2144 retval(2) = std::string ();
2145 retval(1) = std::string ();
2148 int nargin = args.
length ();
2150 if (nargin == 1 || nargin == 2)
2152 if (args(0).is_string ())
2154 std::string tmpl8 = args(0).string_value ();
2157 strcpy (tmp, tmpl8.c_str ());
2159 int fd = gnulib::mkostemp (tmp, O_BINARY);
2163 retval(2) = gnulib::strerror (errno);
2168 const char *fopen_mode =
"w+b";
2170 FILE *fid = fdopen (fd, fopen_mode);
2174 std::string nm = tmp;
2185 if (nargin == 2 && args(1).
is_true ())
2189 error (
"mkstemp: failed to create octave_stdiostream object");
2193 retval(2) = gnulib::strerror (errno);
2199 error (
"mkstemp: TEMPLATE argument must be a string");
2212 int tmp = x % obase;
2214 if (tmp > ibase - 1)
2215 ::error (
"umask: invalid digit");
2220 while ((x = (x - tmp) / obase))
2223 if (tmp > ibase - 1)
2225 ::error (
"umask: invalid digit");
2228 retval += mult * tmp;
2238 @deftypefn {Built-in Function} {} umask (@var{mask})\n\
2239 Set the permission mask for file creation.\n\
2241 The parameter @var{mask} is an integer, interpreted as an octal number.\n\
2243 If successful, returns the previous value of the mask (as an integer to be\n\
2244 interpreted as an octal number); otherwise an error message is printed.\n\
2246 The permission mask is a UNIX concept used when creating new objects on a\n\
2247 file system such as files, directories, or named FIFOs. The object to be\n\
2248 created has base permissions in an octal number @var{mode} which are\n\
2249 modified according to the octal value of @var{mask}. The final permissions\n\
2250 for the new object are @code{@var{mode} - @var{mask}}.\n\
2251 @seealso{fopen, mkdir, mkfifo}\n\
2258 if (args.length () == 1)
2260 int mask = args(0).int_value (
true);
2267 ::error (
"umask: MASK must be a positive integer value");
2271 int oct_mask =
convert (mask, 8, 10);
2280 ::error (
"umask: MASK must be an integer");
2297 int nargin = args.
length ();
2309 @deftypefn {Built-in Function} {} P_tmpdir ()\n\
2310 Return the name of the host system's @strong{default} directory for\n\
2313 Programming Note: The value returned by @code{P_tmpdir} is always the\n\
2314 default location. This value may not agree with that returned from\n\
2315 @code{tempdir} if the user has overridden the default with the @env{TMPDIR}\n\
2316 environment variable.\n\
2317 @seealso{tempdir, tempname, mkstemp, tmpfile}\n\
2322 int nargin = args.
length ();
2337 @deftypefn {Built-in Function} {} SEEK_SET ()\n\
2338 @deftypefnx {Built-in Function} {} SEEK_CUR ()\n\
2339 @deftypefnx {Built-in Function} {} SEEK_END ()\n\
2340 Return the numerical value to pass to @code{fseek} to perform one of the\n\
2341 following actions:\n\
2345 Position file relative to the beginning.\n\
2348 Position file relative to the current position.\n\
2351 Position file relative to the end.\n\
2361 @deftypefn {Built-in Function} {} SEEK_CUR ()\n\
2362 Return the numerical value to pass to @code{fseek} to\n\
2363 position the file pointer relative to the current position.\n\
2364 @seealso{SEEK_SET, SEEK_END}\n\
2372 @deftypefn {Built-in Function} {} SEEK_END ()\n\
2373 Return the numerical value to pass to @code{fseek} to\n\
2374 position the file pointer relative to the end of the file.\n\
2375 @seealso{SEEK_SET, SEEK_CUR}\n\
2387 int nargin = args.
length ();
2399 @deftypefn {Built-in Function} {} stdin ()\n\
2400 Return the numeric value corresponding to the standard input stream.\n\
2402 When Octave is used interactively, stdin is filtered through the command\n\
2403 line editing functions.\n\
2404 @seealso{stdout, stderr}\n\
2412 @deftypefn {Built-in Function} {} stdout ()\n\
2413 Return the numeric value corresponding to the standard output stream.\n\
2415 Data written to the standard output is normally filtered through the pager.\n\
2416 @seealso{stdin, stderr}\n\
2424 @deftypefn {Built-in Function} {} stderr ()\n\
2425 Return the numeric value corresponding to the standard error stream.\n\
2427 Even if paging is turned on, the standard error is not sent to the pager.\n\
2428 It is useful for error messages and prompts.\n\
2429 @seealso{stdin, stdout}\n\
static octave_stream do_stream_open(const std::string &name, const std::string &mode_arg, const std::string &arch, int &fid)
void warning_with_id(const char *id, const char *fmt,...)
static std::ios::openmode fopen_mode_to_ios_mode(const std::string &mode)
static void clear(octave_shlib &oct_file)
static octave_stream lookup(int fid, const std::string &who=std::string())
bool is_true(const std::string &s)
std::string find_data_file_in_load_path(const std::string &fcn, const std::string &file, bool require_regular_file)
static octave_stream stdout_stream
octave_value read(const Array< double > &size, octave_idx_type block_size, oct_data_conv::data_type input_type, oct_data_conv::data_type output_type, octave_idx_type skip, oct_mach_info::float_format flt_fmt, octave_idx_type &count)
static octave_value do_fread(octave_stream &os, const octave_value &size_arg, const octave_value &prec_arg, const octave_value &skip_arg, const octave_value &arch_arg, octave_idx_type &count)
static octave_value stdin_file
static std::string get_sscanf_data(const octave_value &val)
octave_value reshape(const dim_vector &dv) const
static octave_stream stdin_stream
OCTINTERP_API void print_usage(void)
static string_vector get_info(int fid)
octave_idx_type length(void) const
OCTAVE_EXPORT octave_value_list FP_tmpdir(const octave_value_list &args, int)
std::string gets(octave_idx_type max_len, bool &err, const std::string &who)
int seek(off_t offset, int origin)
OCTAVE_EXPORT octave_value_list Fpopen(const octave_value_list &args, int)
int int_value(bool req_int=false, bool frc_str_conv=false) const
FloatComplex(* fptr)(const FloatComplex &, float, int, octave_idx_type &)
#define DEFUN(name, args_name, nargout_name, doc)
void error(const char *fmt,...)
double lo_ieee_inf_value(void)
static void normalize_fopen_mode(std::string &mode, bool &use_zlib)
off_t skipl(off_t count, bool &err, const std::string &who)
static float_format string_to_float_format(const std::string &)
static octave_value stdout_file
static std::string tilde_expand(const std::string &)
void cleanup_tmp_files(void)
int printf(const std::string &fmt, const octave_value_list &args, const std::string &who)
OCTAVE_EXPORT octave_value_list Fstdout(const octave_value_list &args, int)
static int do_fwrite(octave_stream &os, const octave_value &data, const octave_value &prec_arg, const octave_value &skip_arg, const octave_value &arch_arg)
static octave_stream create(const std::string &n, gzFile f=0, int fid=0, std::ios::openmode m=std::ios::in|std::ios::out, oct_mach_info::float_format ff=oct_mach_info::native_float_format(), c_zfile_ptr_buf::close_fcn cf=c_zfile_ptr_buf::file_close)
static octave_stream stderr_stream
std::stack< std::string > tmp_files
static int insert(octave_stream &os)
static int remove(int fid, const std::string &who=std::string())
octave_idx_type numel(const octave_value_list &idx)
OCTAVE_EXPORT octave_value_list FSEEK_CUR(const octave_value_list &args, int)
std::string string_value(bool force=false) const
static octave_stream create(const std::string &n, FILE *f=0, std::ios::openmode m=std::ios::in|std::ios::out, oct_mach_info::float_format ff=oct_mach_info::native_float_format(), c_file_ptr_buf::close_fcn cf=c_file_ptr_buf::file_close)
bool is_string(void) const
static octave_value stderr_file
#define DEFUNX(name, fname, args_name, nargout_name, doc)
static octave_stream create(const std::string &n, std::ios::openmode arg_md=std::ios::out, oct_mach_info::float_format flt_fmt=oct_mach_info::native_float_format())
OCTAVE_EXPORT octave_value_list FSEEK_END(const octave_value_list &args, int)
int puts(const std::string &s, const std::string &who)
static void clear(bool flush=true)
OCTAVE_EXPORT octave_value_list Ffscanf(const octave_value_list &args, int)
OCTAVE_EXPORT octave_value_list Ffeof(const octave_value_list &args, int)
std::string error(bool clear, int &err_num)
OCTAVE_EXPORT octave_value_list Fferror(const octave_value_list &args, int)
octave_value_list oscanf(const std::string &fmt, const std::string &who)
octave_idx_type length(void) const
size_t size(T const (&)[z])
octave_value scanf(const std::string &fmt, const Array< double > &size, octave_idx_type &count, const std::string &who)
int octave_umask(mode_t mode)
OCTAVE_EXPORT octave_value_list FSEEK_SET(const octave_value_list &args, int)
void warning(const char *fmt,...)
OCTAVE_EXPORT octave_value_list Fpclose(const octave_value_list &args, int)
Handles the reference counting for all the derived classes.
void mark_for_deletion(const std::string &file)
OCTAVE_EXPORT octave_value_list Fumask(const octave_value_list &args, int)
bool is_sq_string(void) const
static octave_stream create(const char *data, std::ios::openmode arg_md=std::ios::out, oct_mach_info::float_format ff=oct_mach_info::native_float_format())
bool is_valid(void) const
static octave_value const_value(const char *, const octave_value_list &args, int val)
static std::string list_open_files(void)
octave_idx_type write(const octave_value &data, octave_idx_type block_size, oct_data_conv::data_type output_type, octave_idx_type skip, oct_mach_info::float_format flt_fmt)
static octave_value open_file_numbers(void)
OCTAVE_EXPORT octave_value_list Fstderr(const octave_value_list &args, int)
Array< double > vector_value(bool frc_str_conv=false, bool frc_vec_conv=false) const
static int convert(int x, int ibase, int obase)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
void resize(octave_idx_type n, const octave_value &rfv=octave_value())
static octave_stream create(const std::string &n, std::ios::openmode arg_md=std::ios::in, oct_mach_info::float_format flt_fmt=oct_mach_info::native_float_format())
static data_type string_to_data_type(const std::string &s)
static octave_stream create(std::istream *arg=0, const std::string &n=std::string())
static octave_stream create(std::ostream *arg, const std::string &n=std::string())
void initialize_file_io(void)
std::string get_P_tmpdir(void)
std::string getl(octave_idx_type max_len, bool &err, const std::string &who)
static int get_file_number(const octave_value &fid)
std::string octave_tempnam(const std::string &dir, const std::string &pfx)
OCTAVE_EXPORT octave_value_list Fstdin(const octave_value_list &args, int)
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))
F77_RET_T const double * x