#include <cerrno>
#include <climits>
#include <cstdio>
#include <iostream>
#include <stack>
#include <vector>
#include <fcntl.h>
#include <sys/types.h>
#include <unistd.h>
#include "error.h"
#include "file-ops.h"
#include "file-stat.h"
#include "lo-ieee.h"
#include "oct-env.h"
#include "oct-locbuf.h"
#include "defun.h"
#include "file-io.h"
#include "load-path.h"
#include "oct-fstrm.h"
#include "oct-iostrm.h"
#include "oct-map.h"
#include "oct-obj.h"
#include "oct-prcstrm.h"
#include "oct-stream.h"
#include "oct-strstrm.h"
#include "pager.h"
#include "sysdep.h"
#include "utils.h"
#include "variables.h"
Go to the source code of this file.
Functions | |
void | cleanup_tmp_files (void) |
void | close_files (void) |
static octave_value | const_value (const char *, const octave_value_list &args, int val) |
static octave_value | const_value (const char *, const octave_value_list &args, const octave_value &val) |
static int | convert (int x, int ibase, int obase) |
DEFALIAS (octave_tmp_file_name, tmpnam) | |
DEFUN (sprintf, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} sprintf (@var{template}, @dots{})\n\ This is like @code{printf}, except that the output is returned as a\n\ string. Unlike the C library function, which requires you to provide a\n\ suitably sized string as an argument, Octave's @code{sprintf} function\n\ returns the string, automatically sized to hold all of the items\n\ converted.\n\ @seealso{printf, fprintf, sscanf}\n\ @end deftypefn") | |
DEFUN (frewind, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} frewind (@var{fid})\n\ Move the file pointer to the beginning of the file @var{fid}, returning\n\ 0 for success, and -1 if an error was encountered. It is equivalent to\n\ @code{fseek (@var{fid}, 0, SEEK_SET)}.\n\ @end deftypefn") | |
DEFUN (fseek, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} fseek (@var{fid}, @var{offset}, @var{origin})\n\ Set the file pointer to any location within the file @var{fid}.\n\ \n\ The pointer is positioned @var{offset} characters from the @var{origin},\n\ which may be one of the predefined variables @w{@code{SEEK_CUR}} (current\n\ position), @w{@code{SEEK_SET}} (beginning), or @w{@code{SEEK_END}} (end of\n\ file) or strings \"cof\", \"bof\" or \"eof\". If @var{origin} is omitted,\n\ @w{@code{SEEK_SET}} is assumed. The offset must be zero, or a value returned\n\ by @code{ftell} (in which case @var{origin} must be @w{@code{SEEK_SET}}).\n\ \n\ Return 0 on success and -1 on error.\n\ @seealso{ftell, fopen, fclose}\n\ @end deftypefn") | |
DEFUN (popen, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{fid} =} popen (@var{command}, @var{mode})\n\ Start a process and create a pipe. The name of the command to run is\n\ given by @var{command}. The file identifier corresponding to the input\n\ or output stream of the process is returned in @var{fid}. The argument\n\ @var{mode} may be\n\ \n\ @table @code\n\ @item \"r\"\n\ The pipe will be connected to the standard output of the process, and\n\ open for reading.\n\ \n\ @item \"w\"\n\ The pipe will be connected to the standard input of the process, and\n\ open for writing.\n\ @end table\n\ \n\ For example:\n\ \n\ @example\n\ @group\n\ fid = popen (\"ls -ltr / | tail -3\", \"r\");\n\ while (ischar (s = fgets (fid)))\n\ fputs (stdout, s);\n\ endwhile\n\ @print{} drwxr-xr-x 33 root root 3072 Feb 15 13:28 etc\n\ @print{} drwxr-xr-x 3 root root 1024 Feb 15 13:28 lib\n\ @print{} drwxrwxrwt 15 root root 2048 Feb 17 14:53 tmp\n\ @end group\n\ @end example\n\ @end deftypefn") | |
DEFUN (pclose, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} pclose (@var{fid})\n\ Close a file identifier that was opened by @code{popen}. You may also\n\ use @code{fclose} for the same purpose.\n\ @end deftypefn") | |
DEFUN (fflush, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} fflush (@var{fid})\n\ Flush output to @var{fid}. This is useful for ensuring that all\n\ pending output makes it to the screen before some other event occurs.\n\ For example, it is always a good idea to flush the standard output\n\ stream before calling @code{input}.\n\ \n\ @code{fflush} returns 0 on success and an OS dependent error value\n\ (@minus{}1 on Unix) on error.\n\ @seealso{fopen, fclose}\n\ @end deftypefn") | |
DEFUN (mkstemp, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{fid}, @var{name}, @var{msg}] =} mkstemp (@var{template}, @var{delete})\n\ Return the file ID corresponding to a new temporary file with a unique\n\ name created from @var{template}. The last six characters of @var{template}\n\ must be @code{XXXXXX} and these are replaced with a string that makes the\n\ filename unique. The file is then created with mode read/write and\n\ permissions that are system dependent (on GNU/Linux systems, the permissions\n\ will be 0600 for versions of glibc 2.0.7 and later). The file is opened\n\ in binary mode and with the @w{@code{O_EXCL}} flag.\n\ \n\ If the optional argument @var{delete} is supplied and is true,\n\ the file will be deleted automatically when Octave exits, or when\n\ the function @code{purge_tmp_files} is called.\n\ \n\ If successful, @var{fid} is a valid file ID, @var{name} is the name of\n\ the file, and @var{msg} is an empty string. Otherwise, @var{fid}\n\ is -1, @var{name} is empty, and @var{msg} contains a system-dependent\n\ error message.\n\ @seealso{tmpfile, tmpnam, P_tmpdir}\n\ @end deftypefn") | |
DEFUN (fgetl, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} fgetl (@var{fid}, @var{len})\n\ Read characters from a file, stopping after a newline, or EOF,\n\ or @var{len} characters have been read. The characters read, excluding\n\ the possible trailing newline, are returned as a string.\n\ \n\ If @var{len} is omitted, @code{fgetl} reads until the next newline\n\ character.\n\ \n\ If there are no more characters to read, @code{fgetl} returns @minus{}1.\n\ @seealso{fread, fscanf}\n\ @end deftypefn") | |
DEFUN (ftell, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} ftell (@var{fid})\n\ Return the position of the file pointer as the number of characters\n\ from the beginning of the file @var{fid}.\n\ @seealso{fseek, fopen, fclose}\n\ @end deftypefn") | |
DEFUN (fprintf, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} fprintf (@var{fid}, @var{template}, @dots{})\n\ This function is just like @code{printf}, except that the output is\n\ written to the stream @var{fid} instead of @code{stdout}.\n\ If @var{fid} is omitted, the output is written to @code{stdout}.\n\ @seealso{printf, sprintf, fread, fscanf, fopen, fclose}\n\ @end deftypefn") | |
DEFUN (tmpfile, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{fid}, @var{msg}] =} tmpfile ()\n\ Return the file ID corresponding to a new temporary file with a unique\n\ name. The file is opened in binary read/write (@code{\"w+b\"}) mode.\n\ The file will be deleted automatically when it is closed or when Octave\n\ exits.\n\ \n\ If successful, @var{fid} is a valid file ID and @var{msg} is an empty\n\ string. Otherwise, @var{fid} is -1 and @var{msg} contains a\n\ system-dependent error message.\n\ @seealso{tmpnam, mkstemp, P_tmpdir}\n\ @end deftypefn") | |
DEFUN (printf, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} printf (@var{template}, @dots{})\n\ Print optional arguments under the control of the template string\n\ @var{template} to the stream @code{stdout} and return the number of\n\ characters printed.\n\ @ifclear OCTAVE_MANUAL\n\ \n\ See the Formatted Output section of the GNU Octave manual for a\n\ complete description of the syntax of the template string.\n\ @end ifclear\n\ @seealso{fprintf, sprintf, scanf}\n\ @end deftypefn") | |
DEFUN (fgets, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} fgets (@var{fid})\n\ @deftypefnx {Built-in Function} {} fgets (@var{fid}, @var{len})\n\ Read characters from a file, stopping after a newline, or EOF,\n\ or @var{len} characters have been read. The characters read, including\n\ the possible trailing newline, are returned as a string.\n\ \n\ If @var{len} is omitted, @code{fgets} reads until the next newline\n\ character.\n\ \n\ If there are no more characters to read, @code{fgets} returns @minus{}1.\n\ @seealso{fputs, fopen, fread, fscanf}\n\ @end deftypefn") | |
DEFUN (fputs, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} fputs (@var{fid}, @var{string})\n\ Write a string to a file with no formatting.\n\ \n\ Return a non-negative number on success and EOF on error.\n\ @seealso{scanf, sscanf, fread, fprintf, fgets, fscanf}\n\ @end deftypefn") | |
DEFUN (fwrite, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{count} =} fwrite (@var{fid}, @var{data}, @var{precision}, @var{skip}, @var{arch})\n\ Write data in binary form of type @var{precision} to the specified file\n\ ID @var{fid}, returning the number of values successfully written to the\n\ file.\n\ \n\ The argument @var{data} is a matrix of values that are to be written to\n\ the file. The values are extracted in column-major order.\n\ \n\ The remaining arguments @var{precision}, @var{skip}, and @var{arch} are\n\ optional, and are interpreted as described for @code{fread}.\n\ \n\ The behavior of @code{fwrite} is undefined if the values in @var{data}\n\ are too large to fit in the specified precision.\n\ @seealso{fread, fopen, fclose}\n\ @end deftypefn") | |
DEFUN (puts, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} puts (@var{string})\n\ Write a string to the standard output with no formatting.\n\ \n\ Return a non-negative number on success and EOF on error.\n\ @end deftypefn") | |
DEFUN (fread, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{val}, @var{count}] =} fread (@var{fid}, @var{size}, @var{precision}, @var{skip}, @var{arch})\n\ Read binary data of type @var{precision} from the specified file ID\n\ @var{fid}.\n\ \n\ The optional argument @var{size} specifies the amount of data to read\n\ and may be one of\n\ \n\ @table @code\n\ @item Inf\n\ Read as much as possible, returning a column vector.\n\ \n\ @item @var{nr}\n\ Read up to @var{nr} elements, returning a column vector.\n\ \n\ @item [@var{nr}, Inf]\n\ Read as much as possible, returning a matrix with @var{nr} rows. If the\n\ number of elements read is not an exact multiple of @var{nr}, the last\n\ column is padded with zeros.\n\ \n\ @item [@var{nr}, @var{nc}]\n\ Read up to @code{@var{nr} * @var{nc}} elements, returning a matrix with\n\ @var{nr} rows. If the number of elements read is not an exact multiple\n\ of @var{nr}, the last column is padded with zeros.\n\ @end table\n\ \n\ @noindent\n\ If @var{size} is omitted, a value of @code{Inf} is assumed.\n\ \n\ The optional argument @var{precision} is a string specifying the type of\n\ data to read and may be one of\n\ \n\ @table @asis\n\ @item \"schar\"\n\ @itemx \"signed char\"\n\ Signed character.\n\ \n\ @item \"uchar\"\n\ @itemx \"unsigned char\"\n\ Unsigned character.\n\ \n\ @item \"int8\"\n\ @itemx \"integer*1\"\n\ \n\ 8-bit signed integer.\n\ \n\ @item \"int16\"\n\ @itemx \"integer*2\"\n\ 16-bit signed integer.\n\ \n\ @item \"int32\"\n\ @itemx \"integer*4\"\n\ 32-bit signed integer.\n\ \n\ @item \"int64\"\n\ @itemx \"integer*8\"\n\ 64-bit signed integer.\n\ \n\ @item \"uint8\"\n\ 8-bit unsigned integer.\n\ \n\ @item \"uint16\"\n\ 16-bit unsigned integer.\n\ \n\ @item \"uint32\"\n\ 32-bit unsigned integer.\n\ \n\ @item \"uint64\"\n\ 64-bit unsigned integer.\n\ \n\ @item \"single\"\n\ @itemx \"float32\"\n\ @itemx \"real*4\"\n\ 32-bit floating point number.\n\ \n\ @item \"double\"\n\ @itemx \"float64\"\n\ @itemx \"real*8\"\n\ 64-bit floating point number.\n\ \n\ @item \"char\"\n\ @itemx \"char*1\"\n\ Single character.\n\ \n\ @item \"short\"\n\ Short integer (size is platform dependent).\n\ \n\ @item \"int\"\n\ Integer (size is platform dependent).\n\ \n\ @item \"long\"\n\ Long integer (size is platform dependent).\n\ \n\ @item \"ushort\"\n\ @itemx \"unsigned short\"\n\ Unsigned short integer (size is platform dependent).\n\ \n\ @item \"uint\"\n\ @itemx \"unsigned int\"\n\ Unsigned integer (size is platform dependent).\n\ \n\ @item \"ulong\"\n\ @itemx \"unsigned long\"\n\ Unsigned long integer (size is platform dependent).\n\ \n\ @item \"float\"\n\ Single precision floating point number (size is platform dependent).\n\ @end table\n\ \n\ @noindent\n\ The default precision is @code{\"uchar\"}.\n\ \n\ The @var{precision} argument may also specify an optional repeat\n\ count. For example, @samp{32*single} causes @code{fread} to read\n\ a block of 32 single precision floating point numbers. Reading in\n\ blocks is useful in combination with the @var{skip} argument.\n\ \n\ The @var{precision} argument may also specify a type conversion.\n\ For example, @samp{int16=>int32} causes @code{fread} to read 16-bit\n\ integer values and return an array of 32-bit integer values. By\n\ default, @code{fread} returns a double precision array. The special\n\ form @samp{*TYPE} is shorthand for @samp{TYPE=>TYPE}.\n\ \n\ The conversion and repeat counts may be combined. For example, the\n\ specification @samp{32*single=>single} causes @code{fread} to read\n\ blocks of single precision floating point values and return an array\n\ of single precision values instead of the default array of double\n\ precision values.\n\ \n\ The optional argument @var{skip} specifies the number of bytes to skip\n\ after each element (or block of elements) is read. If it is not\n\ specified, a value of 0 is assumed. If the final block read is not\n\ complete, the final skip is omitted. For example,\n\ \n\ @example\n\ fread (f, 10, \"3*single=>single\", 8)\n\ @end example\n\ \n\ @noindent\n\ will omit the final 8-byte skip because the last read will not be\n\ a complete block of 3 values.\n\ \n\ The optional argument @var{arch} is a string specifying the data format\n\ for the file. Valid values are\n\ \n\ @table @code\n\ @item \"native\"\n\ The format of the current machine.\n\ \n\ @item \"ieee-be\"\n\ IEEE big endian.\n\ \n\ @item \"ieee-le\"\n\ IEEE little endian.\n\ \n\ @item \"vaxd\"\n\ VAX D floating format.\n\ \n\ @item \"vaxg\"\n\ VAX G floating format.\n\ \n\ @item \"cray\"\n\ Cray floating format.\n\ @end table\n\ \n\ @noindent\n\ Conversions are currently only supported for @code{\"ieee-be\"} and\n\ @code{\"ieee-le\"} formats.\n\ \n\ The data read from the file is returned in @var{val}, and the number of\n\ values read is returned in @code{count}\n\ @seealso{fwrite, fopen, fclose}\n\ @end deftypefn") | |
DEFUN (fskipl, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} fskipl (@var{fid}, @var{count})\n\ Skip a given number of lines, i.e., discards characters until an end-of-line\n\ is met exactly @var{count}-times, or end-of-file occurs.\n\ Returns the number of lines skipped (end-of-line sequences encountered).\n\ If @var{count} is omitted, it defaults to 1. @var{count} may also be\n\ @code{Inf}, in which case lines are skipped to the end of file.\n\ This form is suitable for counting lines in a file.\n\ @seealso{fgetl, fgets}\n\ @end deftypefn") | |
DEFUN (scanf, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{val}, @var{count}, @var{errmsg}] =} scanf (@var{template}, @var{size})\n\ @deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}, @var{errmsg}]] =} scanf (@var{template}, \"C\")\n\ This is equivalent to calling @code{fscanf} with @var{fid} = @code{stdin}.\n\ \n\ It is currently not useful to call @code{scanf} in interactive\n\ programs.\n\ @seealso{fscanf, sscanf, printf}\n\ @end deftypefn") | |
DEFUN (fclose, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} fclose (@var{fid})\n\ @deftypefnx {Built-in Function} {} fclose (\"all\")\n\ Close the specified file. If successful, @code{fclose} returns 0,\n\ otherwise, it returns -1. The second form of the @code{fclose} call closes\n\ all open files except @code{stdout}, @code{stderr}, and @code{stdin}.\n\ @seealso{fopen, fseek, ftell}\n\ @end deftypefn") | |
DEFUN (fscanf, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{val}, @var{count}, @var{errmsg}] =} fscanf (@var{fid}, @var{template}, @var{size})\n\ @deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}, @var{errmsg}] =} fscanf (@var{fid}, @var{template}, \"C\")\n\ In the first form, read from @var{fid} according to @var{template},\n\ returning the result in the matrix @var{val}.\n\ \n\ The optional argument @var{size} specifies the amount of data to read\n\ and may be one of\n\ \n\ @table @code\n\ @item Inf\n\ Read as much as possible, returning a column vector.\n\ \n\ @item @var{nr}\n\ Read up to @var{nr} elements, returning a column vector.\n\ \n\ @item [@var{nr}, Inf]\n\ Read as much as possible, returning a matrix with @var{nr} rows. If the\n\ number of elements read is not an exact multiple of @var{nr}, the last\n\ column is padded with zeros.\n\ \n\ @item [@var{nr}, @var{nc}]\n\ Read up to @code{@var{nr} * @var{nc}} elements, returning a matrix with\n\ @var{nr} rows. If the number of elements read is not an exact multiple\n\ of @var{nr}, the last column is padded with zeros.\n\ @end table\n\ \n\ @noindent\n\ If @var{size} is omitted, a value of @code{Inf} is assumed.\n\ \n\ A string is returned if @var{template} specifies only character\n\ conversions.\n\ \n\ The number of items successfully read is returned in @var{count}.\n\ \n\ If an error occurs, @var{errmsg} contains a system-dependent error message.\n\ \n\ In the second form, read from @var{fid} according to @var{template},\n\ with each conversion specifier in @var{template} corresponding to a\n\ single scalar return value. This form is more `C-like', and also\n\ compatible with previous versions of Octave. The number of successful\n\ conversions is returned in @var{count}\n\ @ifclear OCTAVE_MANUAL\n\ \n\ See the Formatted Input section of the GNU Octave manual for a\n\ complete description of the syntax of the template string.\n\ @end ifclear\n\ @seealso{scanf, sscanf, fread, fprintf, fgets, fputs}\n\ @end deftypefn") | |
DEFUN (sscanf, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{val}, @var{count}, @var{errmsg}, @var{pos}] =} sscanf (@var{string}, @var{template}, @var{size})\n\ @deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}, @var{errmsg}] =} sscanf (@var{string}, @var{template}, \"C\")\n\ This is like @code{fscanf}, except that the characters are taken from the\n\ string @var{string} instead of from a stream. Reaching the end of the\n\ string is treated as an end-of-file condition. In addition to the values\n\ returned by @code{fscanf}, the index of the next character to be read\n\ is returned in @var{pos}.\n\ @seealso{fscanf, scanf, sprintf}\n\ @end deftypefn") | |
DEFUN (fclear, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} fclear (@var{fid})\n\ Clear the stream state for the specified file.\n\ @end deftypefn") | |
DEFUN (fopen, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{fid}, @var{msg}] =} fopen (@var{name}, @var{mode}, @var{arch})\n\ @deftypefnx {Built-in Function} {@var{fid_list} =} fopen (\"all\")\n\ @deftypefnx {Built-in Function} {[@var{file}, @var{mode}, @var{arch}] =} fopen (@var{fid})\n\ The first form of the @code{fopen} function opens the named file with\n\ the specified mode (read-write, read-only, etc.) and architecture\n\ interpretation (IEEE big endian, IEEE little endian, etc.), and returns\n\ an integer value that may be used to refer to the file later. If an\n\ error occurs, @var{fid} is set to @minus{}1 and @var{msg} contains the\n\ corresponding system error message. The @var{mode} is a one or two\n\ character string that specifies whether the file is to be opened for\n\ reading, writing, or both.\n\ \n\ The second form of the @code{fopen} function returns a vector of file ids\n\ corresponding to all the currently open files, excluding the\n\ @code{stdin}, @code{stdout}, and @code{stderr} streams.\n\ \n\ The third form of the @code{fopen} function returns information about the\n\ open file given its file id.\n\ \n\ For example,\n\ \n\ @example\n\ myfile = fopen (\"splat.dat\", \"r\", \"ieee-le\");\n\ @end example\n\ \n\ @noindent\n\ opens the file @file{splat.dat} for reading. If necessary, binary\n\ numeric values will be read assuming they are stored in IEEE format with\n\ the least significant bit first, and then converted to the native\n\ representation.\n\ \n\ Opening a file that is already open simply opens it again and returns a\n\ separate file id. It is not an error to open a file several times,\n\ though writing to the same file through several different file ids may\n\ produce unexpected results.\n\ \n\ The possible values @samp{mode} may have are\n\ \n\ @table @asis\n\ @item @samp{r}\n\ Open a file for reading.\n\ \n\ @item @samp{w}\n\ Open a file for writing. The previous contents are discarded.\n\ \n\ @item @samp{a}\n\ Open or create a file for writing at the end of the file.\n\ \n\ @item @samp{r+}\n\ Open an existing file for reading and writing.\n\ \n\ @item @samp{w+}\n\ Open a file for reading or writing. The previous contents are\n\ discarded.\n\ \n\ @item @samp{a+}\n\ Open or create a file for reading or writing at the end of the\n\ file.\n\ @end table\n\ \n\ Append a \"t\" to the mode string to open the file in text mode or a\n\ \"b\" to open in binary mode. On Windows and Macintosh systems, text\n\ mode reading and writing automatically converts linefeeds to the\n\ appropriate line end character for the system (carriage-return linefeed\n\ on Windows, carriage-return on Macintosh). The default if no mode is\n\ specified is binary mode.\n\ \n\ Additionally, you may append a \"z\" to the mode string to open a\n\ gzipped file for reading or writing. For this to be successful, you\n\ must also open the file in binary mode.\n\ \n\ The parameter @var{arch} is a string specifying the default data format\n\ for the file. Valid values for @var{arch} are:\n\ \n\ @table @asis\n\ @samp{native}\n\ The format of the current machine (this is the default).\n\ \n\ @samp{ieee-be}\n\ IEEE big endian format.\n\ \n\ @samp{ieee-le}\n\ IEEE little endian format.\n\ \n\ @samp{vaxd}\n\ VAX D floating format.\n\ \n\ @samp{vaxg}\n\ VAX G floating format.\n\ \n\ @samp{cray}\n\ Cray floating format.\n\ @end table\n\ \n\ @noindent\n\ however, conversions are currently only supported for @samp{native}\n\ @samp{ieee-be}, and @samp{ieee-le} formats.\n\ @seealso{fclose, fgets, fputs, fread, fseek, ferror, fprintf, fscanf, ftell, fwrite}\n\ @end deftypefn") | |
DEFUN (freport, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} freport ()\n\ Print a list of which files have been opened, and whether they are open\n\ for reading, writing, or both. For example:\n\ \n\ @example\n\ @group\n\ freport ()\n\ \n\ @print{} number mode name\n\ @print{}\n\ @print{} 0 r stdin\n\ @print{} 1 w stdout\n\ @print{} 2 w stderr\n\ @print{} 3 r myfile\n\ @end group\n\ @end example\n\ @end deftypefn") | |
DEFUNX ("P_tmpdir", FP_tmpdir, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} P_tmpdir ()\n\ Return the default name of the directory for temporary files on\n\ this system. The name of this directory is system dependent.\n\ @end deftypefn") | |
DEFUNX ("feof", Ffeof, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} feof (@var{fid})\n\ Return 1 if an end-of-file condition has been encountered for a given\n\ file and 0 otherwise. Note that it will only return 1 if the end of the\n\ file has already been encountered, not if the next read operation will\n\ result in an end-of-file condition.\n\ @seealso{fread, fopen, fclose}\n\ @end deftypefn") | |
DEFUNX ("ferror", Fferror, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} ferror (@var{fid}, \"clear\")\n\ Return 1 if an error condition has been encountered for the file ID\n\ @var{fid} and 0 otherwise. Note that it will only return 1 if an error\n\ has already been encountered, not if the next operation will result in\n\ an error condition.\n\ \n\ The second argument is optional. If it is supplied, also clear the\n\ error condition.\n\ @end deftypefn") | |
DEFUNX ("SEEK_END", FSEEK_END, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} SEEK_END ()\n\ Return the numerical value to pass to @code{fseek} to\n\ position the file pointer relative to the end of the file.\n\ @seealso{SEEK_SET, SEEK_CUR}.\n\ @end deftypefn") | |
DEFUNX ("tmpnam", Ftmpnam, args,,"-*- texinfo -*-\n\ @c List other forms of function in documentation index\n\ @findex octave_tmp_file_name\n\ \n\ @deftypefn {Built-in Function} {} tmpnam ()\n\ @deftypefnx {Built-in Function} {} tmpnam (@var{dir})\n\ @deftypefnx {Built-in Function} {} tmpnam (@var{dir}, @var{prefix})\n\ Return a unique temporary file name as a string.\n\ \n\ If @var{prefix} is omitted, a value of @code{\"oct-\"} is used.\n\ If @var{dir} is also omitted, the default directory for temporary files\n\ is used. If @var{dir} is provided, it must exist, otherwise the default\n\ directory for temporary files is used. Since the named file is not\n\ opened, by @code{tmpnam}, it is possible (though relatively unlikely)\n\ that it will not be available by the time your program attempts to open it.\n\ @seealso{tmpfile, mkstemp, P_tmpdir}\n\ @end deftypefn") | |
DEFUNX ("umask", Fumask, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} umask (@var{mask})\n\ Set the permission mask for file creation. The parameter @var{mask}\n\ is an integer, interpreted as an octal number. If successful,\n\ returns the previous value of the mask (as an integer to be\n\ interpreted as an octal number); otherwise an error message is printed.\n\ @end deftypefn") | |
DEFUNX ("SEEK_CUR", FSEEK_CUR, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} SEEK_CUR ()\n\ Return the numerical value to pass to @code{fseek} to\n\ position the file pointer relative to the current position.\n\ @seealso{SEEK_SET, SEEK_END}.\n\ @end deftypefn") | |
DEFUNX ("SEEK_SET", FSEEK_SET, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} SEEK_SET ()\n\ @deftypefnx {Built-in Function} {} SEEK_CUR ()\n\ @deftypefnx {Built-in Function} {} SEEK_END ()\n\ Return the numerical value to pass to @code{fseek} to perform\n\ one of the following actions:\n\ @table @code\n\ @item SEEK_SET\n\ Position file relative to the beginning.\n\ \n\ @item SEEK_CUR\n\ Position file relative to the current position.\n\ \n\ @item SEEK_END\n\ Position file relative to the end.\n\ @end table\n\ @seealso{fseek}\n\ @end deftypefn") | |
DEFUNX ("stderr", Fstderr, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} stderr ()\n\ Return the numeric value corresponding to the standard error stream.\n\ Even if paging is turned on, the standard error is not sent to the\n\ pager. It is useful for error messages and prompts.\n\ @seealso{stdin, stdout}\n\ @end deftypefn") | |
DEFUNX ("stdin", Fstdin, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} stdin ()\n\ Return the numeric value corresponding to the standard input stream.\n\ When Octave is used interactively, this is filtered through the command\n\ line editing functions.\n\ @seealso{stdout, stderr}\n\ @end deftypefn") | |
DEFUNX ("stdout", Fstdout, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} stdout ()\n\ Return the numeric value corresponding to the standard output stream.\n\ Data written to the standard output is normally filtered through the pager.\n\ @seealso{stdin, stderr}\n\ @end deftypefn") | |
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 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 | do_stream_open (const std::string &name, const std::string &mode, const std::string &arch, int &fid) |
static octave_stream | do_stream_open (const octave_value &tc_name, const octave_value &tc_mode, const octave_value &tc_arch, const char *fcn, int &fid) |
static std::ios::openmode | fopen_mode_to_ios_mode (const std::string &mode_arg) |
static std::string | get_sscanf_data (const octave_value &val) |
void | initialize_file_io (void) |
void | mark_for_deletion (const std::string &file) |
Variables | |
static octave_value | stderr_file |
static octave_stream | stderr_stream |
static octave_value | stdin_file |
static octave_stream | stdin_stream |
static octave_value | stdout_file |
static octave_stream | stdout_stream |
std::stack< std::string > | tmp_files |
void cleanup_tmp_files | ( | void | ) |
void close_files | ( | void | ) |
Definition at line 105 of file file-io.cc.
References octave_stream_list::clear().
Referenced by do_octave_atexit().
static octave_value const_value | ( | const char * | , | |
const octave_value_list & | args, | |||
int | val | |||
) | [static] |
Definition at line 2143 of file file-io.cc.
References octave_value_list::length(), and print_usage().
Referenced by DEFUNX().
static octave_value const_value | ( | const char * | , | |
const octave_value_list & | args, | |||
const octave_value & | val | |||
) | [static] |
Definition at line 2225 of file file-io.cc.
References octave_value_list::length(), and print_usage().
DEFALIAS | ( | octave_tmp_file_name | , | |
tmpnam | ||||
) |
DEFUN | ( | sprintf | , | |
args | ||||
) |
Definition at line 1010 of file file-io.cc.
References error(), octave_stream::error(), octave_value::is_sq_string(), octave_value::is_string(), octave_stream::is_valid(), octave_value(), print_usage(), octave_stream::printf(), octave_value_list::resize(), and octave_ostrstream::str().
DEFUN | ( | frewind | , | |
args | , | |||
nargout | ||||
) |
Definition at line 758 of file file-io.cc.
References error_state, octave_stream_list::lookup(), print_usage(), and octave_stream::rewind().
DEFUN | ( | fseek | , | |
args | ||||
) |
Definition at line 788 of file file-io.cc.
References error_state, octave_stream_list::lookup(), octave_value(), print_usage(), and octave_stream::seek().
DEFUN | ( | popen | , | |
args | ||||
) |
Definition at line 1787 of file file-io.cc.
References octave_oprocstream::create(), octave_iprocstream::create(), error(), error_state, octave_stream_list::insert(), and print_usage().
DEFUN | ( | pclose | , | |
args | ||||
) |
Definition at line 1861 of file file-io.cc.
References print_usage(), and octave_stream_list::remove().
DEFUN | ( | fflush | , | |
args | ||||
) |
Definition at line 258 of file file-io.cc.
References error_state, octave_stream::flush(), flush_octave_stdout(), octave_stream_list::get_file_number(), octave_stream_list::lookup(), and print_usage().
DEFUN | ( | mkstemp | , | |
args | ||||
) |
Definition at line 1979 of file file-io.cc.
References octave_stdiostream::create(), error(), error_state, fopen_mode_to_ios_mode(), octave_stream_list::insert(), octave_value_list::length(), mark_for_deletion(), OCTAVE_LOCAL_BUFFER, and print_usage().
DEFUN | ( | fgetl | , | |
args | ||||
) |
Definition at line 301 of file file-io.cc.
References error_state, octave_stream::getl(), octave_value_list::length(), octave_stream_list::lookup(), octave_value(), and print_usage().
DEFUN | ( | ftell | , | |
args | ||||
) |
Definition at line 826 of file file-io.cc.
References error_state, octave_stream_list::lookup(), print_usage(), and octave_stream::tell().
DEFUN | ( | fprintf | , | |
args | , | |||
nargout | ||||
) |
Definition at line 851 of file file-io.cc.
References error(), error_state, octave_stream_list::lookup(), print_usage(), octave_stream::printf(), and octave_value_list::resize().
DEFUN | ( | tmpfile | , | |
args | ||||
) |
Definition at line 1928 of file file-io.cc.
References octave_stdiostream::create(), error(), fopen_mode_to_ios_mode(), octave_stream_list::insert(), octave_value_list::length(), and print_usage().
DEFUN | ( | printf | , | |
args | , | |||
nargout | ||||
) |
Definition at line 912 of file file-io.cc.
References error(), print_usage(), octave_stream::printf(), and octave_value_list::resize().
DEFUN | ( | fgets | , | |
args | ||||
) |
Definition at line 349 of file file-io.cc.
References error_state, octave_stream::gets(), octave_value_list::length(), octave_stream_list::lookup(), octave_value(), and print_usage().
DEFUN | ( | fputs | , | |
args | ||||
) |
Definition at line 962 of file file-io.cc.
References error_state, octave_stream_list::lookup(), print_usage(), and octave_stream::puts().
DEFUN | ( | fwrite | , | |
args | ||||
) |
Definition at line 1651 of file file-io.cc.
References do_fwrite(), error_state, octave_value::is_string(), octave_stream_list::lookup(), and print_usage().
DEFUN | ( | puts | , | |
args | ||||
) |
Definition at line 990 of file file-io.cc.
References print_usage(), and octave_stream::puts().
DEFUN | ( | fread | , | |
args | ||||
) |
Definition at line 1377 of file file-io.cc.
References do_fread(), error_state, octave_value::is_string(), lo_ieee_inf_value(), octave_stream_list::lookup(), print_usage(), and size().
DEFUN | ( | fskipl | , | |
args | ||||
) |
Definition at line 398 of file file-io.cc.
References error_state, octave_stream_list::lookup(), octave_value(), print_usage(), and octave_stream::skipl().
DEFUN | ( | scanf | , | |
args | , | |||
nargout | ||||
) |
Definition at line 1296 of file file-io.cc.
DEFUN | ( | fclose | , | |
args | ||||
) |
Definition at line 211 of file file-io.cc.
References print_usage(), and octave_stream_list::remove().
DEFUN | ( | fscanf | , | |
args | ||||
) |
Definition at line 1070 of file file-io.cc.
References octave_stream::error(), error(), error_state, lo_ieee_inf_value(), octave_stream_list::lookup(), octave_stream::oscanf(), print_usage(), octave_stream::scanf(), and size().
DEFUN | ( | sscanf | , | |
args | ||||
) |
Definition at line 1199 of file file-io.cc.
References octave_istrstream::create(), octave_stream::eof(), octave_stream::error(), error(), error_state, get_sscanf_data(), octave_stream::is_valid(), lo_ieee_inf_value(), octave_stream::oscanf(), print_usage(), octave_stream::scanf(), size(), and octave_stream::tell().
DEFUN | ( | fclear | , | |
args | ||||
) |
Definition at line 233 of file file-io.cc.
References octave_stream::clearerr(), error_state, octave_stream_list::get_file_number(), octave_stream_list::lookup(), and print_usage().
DEFUN | ( | fopen | , | |
args | , | |||
nargout | ||||
) |
Definition at line 560 of file file-io.cc.
References do_stream_open(), octave_stream::error(), error_state, octave_stream_list::get_info(), octave_stream_list::insert(), octave_value_list::length(), octave_value(), octave_stream_list::open_file_numbers(), and print_usage().
DEFUN | ( | freport | , | |
args | ||||
) |
Definition at line 726 of file file-io.cc.
References octave_stream_list::list_open_files(), octave_stdout, and warning().
DEFUNX | ( | "P_tmpdir" | , | |
FP_tmpdir | , | |||
args | ||||
) |
Definition at line 2157 of file file-io.cc.
References get_P_tmpdir(), and print_usage().
DEFUNX | ( | "feof" | , | |
Ffeof | , | |||
args | ||||
) |
Definition at line 1712 of file file-io.cc.
References octave_stream::eof(), error_state, octave_stream_list::lookup(), and print_usage().
DEFUNX | ( | "ferror" | , | |
Fferror | , | |||
args | ||||
) |
Definition at line 1739 of file file-io.cc.
References clear(), octave_stream::error(), error_state, octave_stream_list::lookup(), and print_usage().
DEFUNX | ( | "SEEK_END" | , | |
FSEEK_END | , | |||
args | ||||
) |
Definition at line 2213 of file file-io.cc.
References const_value().
DEFUNX | ( | "tmpnam" | , | |
Ftmpnam | , | |||
args | ||||
) |
Definition at line 1880 of file file-io.cc.
References error(), error_state, octave_tempnam(), and print_usage().
DEFUNX | ( | "umask" | , | |
Fumask | , | |||
args | ||||
) |
Definition at line 2095 of file file-io.cc.
References convert(), error(), error_state, octave_umask(), and print_usage().
DEFUNX | ( | "SEEK_CUR" | , | |
FSEEK_CUR | , | |||
args | ||||
) |
Definition at line 2202 of file file-io.cc.
References const_value().
DEFUNX | ( | "SEEK_SET" | , | |
FSEEK_SET | , | |||
args | ||||
) |
Definition at line 2179 of file file-io.cc.
References const_value().
DEFUNX | ( | "stderr" | , | |
Fstderr | , | |||
args | ||||
) |
Definition at line 2263 of file file-io.cc.
References const_value().
DEFUNX | ( | "stdin" | , | |
Fstdin | , | |||
args | ||||
) |
Definition at line 2240 of file file-io.cc.
References const_value().
DEFUNX | ( | "stdout" | , | |
Fstdout | , | |||
args | ||||
) |
Definition at line 2252 of file file-io.cc.
References const_value().
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] |
Definition at line 1319 of file file-io.cc.
References error(), error_state, octave_value::int_value(), octave_stream::read(), size(), oct_data_conv::string_to_data_type(), oct_mach_info::string_to_float_format(), octave_value::string_value(), and octave_value::vector_value().
Referenced by DEFUN().
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] |
Definition at line 1604 of file file-io.cc.
References error(), error_state, octave_value::int_value(), oct_data_conv::string_to_data_type(), oct_mach_info::string_to_float_format(), octave_value::string_value(), and octave_stream::write().
Referenced by DEFUN().
static octave_stream do_stream_open | ( | const std::string & | name, | |
const std::string & | mode, | |||
const std::string & | arch, | |||
int & | fid | |||
) | [static] |
Definition at line 440 of file file-io.cc.
References octave_env::absolute_pathname(), octave_stdiostream::create(), octave_stream::error(), error_state, base_file_stat::exists(), load_path::find_file(), fopen_mode_to_ios_mode(), base_file_stat::is_dir(), octave_env::make_absolute(), octave_env::rooted_relative_pathname(), oct_mach_info::string_to_float_format(), file_ops::tilde_expand(), and warning_with_id().
Referenced by DEFUN(), and do_stream_open().
static octave_stream do_stream_open | ( | const octave_value & | tc_name, | |
const octave_value & | tc_mode, | |||
const octave_value & | tc_arch, | |||
const char * | fcn, | |||
int & | fid | |||
) | [static] |
Definition at line 529 of file file-io.cc.
References do_stream_open(), error(), error_state, and octave_value::string_value().
static std::ios::openmode fopen_mode_to_ios_mode | ( | const std::string & | mode_arg | ) | [static] |
Definition at line 134 of file file-io.cc.
References error(), error_state, and warning().
Referenced by DEFUN(), and do_stream_open().
static std::string get_sscanf_data | ( | const octave_value & | val | ) | [static] |
Definition at line 1183 of file file-io.cc.
References error(), octave_value::is_string(), octave_value::numel(), octave_value::reshape(), and octave_value::string_value().
Referenced by DEFUN().
void initialize_file_io | ( | void | ) |
Definition at line 88 of file file-io.cc.
References octave_ostream::create(), octave_istream::create(), octave_stream_list::insert(), and octave_stdout.
Referenced by octave_main().
void mark_for_deletion | ( | const std::string & | file | ) |
octave_value stderr_file [static] |
Definition at line 81 of file file-io.cc.
octave_stream stderr_stream [static] |
Definition at line 85 of file file-io.cc.
octave_value stdin_file [static] |
Definition at line 79 of file file-io.cc.
octave_stream stdin_stream [static] |
Definition at line 83 of file file-io.cc.
octave_value stdout_file [static] |
Definition at line 80 of file file-io.cc.
octave_stream stdout_stream [static] |
Definition at line 84 of file file-io.cc.
std::stack<std::string> tmp_files |
Definition at line 114 of file file-io.cc.
Referenced by cleanup_tmp_files(), and mark_for_deletion().