Navigation

Operators and Keywords

Function List:

C++ API

file-io.cc File Reference

#include <cerrno>
#include <climits>
#include <cstdio>
#include <iostream>
#include <stack>
#include <vector>
#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"

Include dependency graph for file-io.cc:


Defines

#define P_tmpdir   "/tmp"

Functions

void initialize_file_io (void)
void close_files (void)
void mark_for_deletion (const std::string &file)
void cleanup_tmp_files (void)
 DEFUN (fclose, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} fclose (@var{fid})\n\ Closes the specified file. If successful, @code{fclose} returns 0,\n\ otherwise, it returns -1.\n\ @seealso{fopen, fseek, ftell}\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 (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 (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 (fgets, args,,"-*- texinfo -*-\n\ @deftypefn {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 (fskipl, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} fskipl (@var{fid}, @var{count})\n\ Skips 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 (fopen, args,,"-*- 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")
 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 (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 (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 (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 (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 (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 (fscanf, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{val}, @var{count}] =} fscanf (@var{fid}, @var{template}, @var{size})\n\ @deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}] =} 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\ 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}] =} sscanf (@var{string}, @var{template}, @var{size})\n\ @deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}] =} 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.\n\ @seealso{fscanf, scanf, sprintf}\n\ @end deftypefn")
 DEFUN (scanf, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{val}, @var{count}] =} scanf (@var{template}, @var{size})\n\ @deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}]] =} 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 (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 @code\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 (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")
 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} {} ferror (@var{fid})\n\ Return 1 if an error condition has been encountered for a given file\n\ and 0 otherwise. Note that it will only return 1 if an error has\n\ already been encountered, not if the next operation will result in an\n\ error condition.\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 (tmpnam, args,,"-*- texinfo -*-\n\ @deftypefn {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")
 DEFALIAS (octave_tmp_file_name, tmpnam)
 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 (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\ 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 (umask, 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 ("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 ("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 value required to request that @code{fseek} 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\ @end deftypefn")
 DEFUNX ("SEEK_CUR", FSEEK_CUR, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} SEEK_CUR ()\n\ See SEEK_SET.\n\ @end deftypefn")
 DEFUNX ("SEEK_END", FSEEK_END, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} SEEK_END ()\n\ See SEEK_SET.\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")
 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")

Variables

std::stack< std::stringtmp_files

Define Documentation

#define P_tmpdir   "/tmp"


Function Documentation

void cleanup_tmp_files ( void   ) 

void close_files ( void   ) 

DEFALIAS ( octave_tmp_file_name  ,
tmpnam   
)

DEFUN ( umask  ,
args   
)

DEFUN ( mkstemp  ,
args   
)

DEFUN ( tmpfile  ,
args   
)

DEFUN ( tmpnam  ,
args   
)

DEFUN ( pclose  ,
args   
)

DEFUN ( popen  ,
args   
)

DEFUN ( fwrite  ,
args   
)

DEFUN ( fread  ,
args   
)

DEFUN ( scanf  ,
args  ,
nargout   
)

DEFUN ( sscanf  ,
args   
)

DEFUN ( fscanf  ,
args   
)

DEFUN ( sprintf  ,
args   
)

DEFUN ( puts  ,
args   
)

DEFUN ( fputs  ,
args   
)

DEFUN ( printf  ,
args  ,
nargout   
)

DEFUN ( fprintf  ,
args  ,
nargout   
)

DEFUN ( ftell  ,
args   
)

DEFUN ( fseek  ,
args   
)

DEFUN ( frewind  ,
args  ,
nargout   
)

DEFUN ( freport  ,
args   
)

DEFUN ( fopen  ,
args   
)

DEFUN ( fskipl  ,
args   
)

DEFUN ( fgets  ,
args   
)

DEFUN ( fgetl  ,
args   
)

DEFUN ( fflush  ,
args   
)

DEFUN ( fclear  ,
args   
)

DEFUN ( fclose  ,
args   
)

DEFUNX ( "stderr"  ,
Fstderr  ,
args   
)

DEFUNX ( "stdout"  ,
Fstdout  ,
args   
)

DEFUNX ( "stdin"  ,
Fstdin  ,
args   
)

DEFUNX ( "SEEK_END"  ,
FSEEK_END  ,
args   
)

DEFUNX ( "SEEK_CUR"  ,
FSEEK_CUR  ,
args   
)

DEFUNX ( "SEEK_SET"  ,
FSEEK_SET  ,
args   
)

DEFUNX ( "P_tmpdir"  ,
FP_tmpdir  ,
args   
)

DEFUNX ( "ferror"  ,
Fferror  ,
args   
)

DEFUNX ( "feof"  ,
Ffeof  ,
args   
)

void initialize_file_io ( void   ) 

void mark_for_deletion ( const std::string file  ) 


Variable Documentation

std::stack<std::string> tmp_files