<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Filesystem Utilities (GNU Octave (version 5.1.0))</title> <meta name="description" content="Filesystem Utilities (GNU Octave (version 5.1.0))"> <meta name="keywords" content="Filesystem Utilities (GNU Octave (version 5.1.0))"> <meta name="resource-type" content="document"> <meta name="distribution" content="global"> <meta name="Generator" content="makeinfo"> <link href="index.html#Top" rel="start" title="Top"> <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index"> <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> <link href="System-Utilities.html#System-Utilities" rel="up" title="System Utilities"> <link href="File-Archiving-Utilities.html#File-Archiving-Utilities" rel="next" title="File Archiving Utilities"> <link href="Timing-Utilities.html#Timing-Utilities" rel="prev" title="Timing Utilities"> <style type="text/css"> <!-- a.summary-letter {text-decoration: none} blockquote.indentedblock {margin-right: 0em} blockquote.smallindentedblock {margin-right: 0em; font-size: smaller} blockquote.smallquotation {font-size: smaller} div.display {margin-left: 3.2em} div.example {margin-left: 3.2em} div.lisp {margin-left: 3.2em} div.smalldisplay {margin-left: 3.2em} div.smallexample {margin-left: 3.2em} div.smalllisp {margin-left: 3.2em} kbd {font-style: oblique} pre.display {font-family: inherit} pre.format {font-family: inherit} pre.menu-comment {font-family: serif} pre.menu-preformatted {font-family: serif} pre.smalldisplay {font-family: inherit; font-size: smaller} pre.smallexample {font-size: smaller} pre.smallformat {font-family: inherit; font-size: smaller} pre.smalllisp {font-size: smaller} span.nolinebreak {white-space: nowrap} span.roman {font-family: initial; font-weight: normal} span.sansserif {font-family: sans-serif; font-weight: normal} ul.no-bullet {list-style: none} --> </style> <link rel="stylesheet" type="text/css" href="octave.css"> </head> <body lang="en"> <a name="Filesystem-Utilities"></a> <div class="header"> <p> Next: <a href="File-Archiving-Utilities.html#File-Archiving-Utilities" accesskey="n" rel="next">File Archiving Utilities</a>, Previous: <a href="Timing-Utilities.html#Timing-Utilities" accesskey="p" rel="prev">Timing Utilities</a>, Up: <a href="System-Utilities.html#System-Utilities" accesskey="u" rel="up">System Utilities</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p> </div> <hr> <a name="Filesystem-Utilities-1"></a> <h3 class="section">36.2 Filesystem Utilities</h3> <p>Octave includes many utility functions for copying, moving, renaming, and deleting files; for creating, reading, and deleting directories; for retrieving status information on files; and for manipulating file and path names. </p> <a name="XREFmovefile"></a><dl> <dt><a name="index-movefile"></a><em></em> <strong>movefile</strong> <em><var>f1</var></em></dt> <dt><a name="index-movefile-1"></a><em></em> <strong>movefile</strong> <em><var>f1</var> <var>f2</var></em></dt> <dt><a name="index-movefile-2"></a><em></em> <strong>movefile</strong> <em><var>f1</var> <var>f2</var> f</em></dt> <dt><a name="index-movefile-3"></a><em></em> <strong>movefile</strong> <em>(<var>f1</var>)</em></dt> <dt><a name="index-movefile-4"></a><em></em> <strong>movefile</strong> <em>(<var>f1</var>, <var>f2</var>)</em></dt> <dt><a name="index-movefile-5"></a><em></em> <strong>movefile</strong> <em>(<var>f1</var>, <var>f2</var>, 'f')</em></dt> <dt><a name="index-movefile-6"></a><em>[<var>status</var>, <var>msg</var>, <var>msgid</var>] =</em> <strong>movefile</strong> <em>(…)</em></dt> <dd><p>Move the source file or directory <var>f1</var> to the destination <var>f2</var>. </p> <p>The name <var>f1</var> may contain globbing patterns, or may be a cell array of strings. If <var>f1</var> expands to multiple filenames, <var>f2</var> must be a directory. </p> <p>If no destination <var>f2</var> is specified then the destination is the present working directory. If <var>f2</var> is a filename then <var>f1</var> is renamed to <var>f2</var>. </p> <p>When the force flag <code>'f'</code> is given any existing files will be overwritten without prompting. </p> <p>If successful, <var>status</var> is 1, and <var>msg</var>, <var>msgid</var> are empty character strings (""). Otherwise, <var>status</var> is 0, <var>msg</var> contains a system-dependent error message, and <var>msgid</var> contains a unique message identifier. Note that the status code is exactly opposite that of the <code>system</code> command. </p> <p><strong>See also:</strong> <a href="#XREFrename">rename</a>, <a href="#XREFcopyfile">copyfile</a>, <a href="#XREFunlink">unlink</a>, <a href="Manipulation-of-Plot-Windows.html#XREFdelete">delete</a>, <a href="#XREFglob">glob</a>. </p></dd></dl> <a name="XREFrename"></a><dl> <dt><a name="index-rename"></a><em></em> <strong>rename</strong> <em><var>old</var> <var>new</var></em></dt> <dt><a name="index-rename-1"></a><em>[<var>err</var>, <var>msg</var>] =</em> <strong>rename</strong> <em>(<var>old</var>, <var>new</var>)</em></dt> <dd><p>Change the name of file <var>old</var> to <var>new</var>. </p> <p>If successful, <var>err</var> is 0 and <var>msg</var> is an empty string. Otherwise, <var>err</var> is nonzero and <var>msg</var> contains a system-dependent error message. </p> <p><strong>See also:</strong> <a href="#XREFmovefile">movefile</a>, <a href="#XREFcopyfile">copyfile</a>, <a href="Current-Working-Directory.html#XREFls">ls</a>, <a href="Current-Working-Directory.html#XREFdir">dir</a>. </p></dd></dl> <a name="XREFcopyfile"></a><dl> <dt><a name="index-copyfile"></a><em></em> <strong>copyfile</strong> <em><var>f1</var> <var>f2</var></em></dt> <dt><a name="index-copyfile-1"></a><em></em> <strong>copyfile</strong> <em><var>f1</var> <var>f2</var> f</em></dt> <dt><a name="index-copyfile-2"></a><em></em> <strong>copyfile</strong> <em>(<var>f1</var>, <var>f2</var>)</em></dt> <dt><a name="index-copyfile-3"></a><em></em> <strong>copyfile</strong> <em>(<var>f1</var>, <var>f2</var>, 'f')</em></dt> <dt><a name="index-copyfile-4"></a><em>[<var>status</var>, <var>msg</var>, <var>msgid</var>] =</em> <strong>copyfile</strong> <em>(…)</em></dt> <dd><p>Copy the source file(s) or directory <var>f1</var> to the destination <var>f2</var>. </p> <p>The name <var>f1</var> may contain globbing patterns, or may be a cell array of strings. If <var>f1</var> expands to multiple filenames, <var>f2</var> must be a directory. </p> <p>When the force flag <code>'f'</code> is given any existing files will be overwritten without prompting. </p> <p>If successful, <var>status</var> is 1, and <var>msg</var>, <var>msgid</var> are empty character strings (""). Otherwise, <var>status</var> is 0, <var>msg</var> contains a system-dependent error message, and <var>msgid</var> contains a unique message identifier. Note that the status code is exactly opposite that of the <code>system</code> command. </p> <p><strong>See also:</strong> <a href="#XREFmovefile">movefile</a>, <a href="#XREFrename">rename</a>, <a href="#XREFunlink">unlink</a>, <a href="Manipulation-of-Plot-Windows.html#XREFdelete">delete</a>, <a href="#XREFglob">glob</a>. </p></dd></dl> <a name="XREFunlink"></a><dl> <dt><a name="index-unlink"></a><em>[<var>err</var>, <var>msg</var>] =</em> <strong>unlink</strong> <em>(<var>file</var>)</em></dt> <dd><p>Delete the file named <var>file</var>. </p> <p>If successful, <var>err</var> is 0 and <var>msg</var> is an empty string. Otherwise, <var>err</var> is nonzero and <var>msg</var> contains a system-dependent error message. </p> <p><strong>See also:</strong> <a href="Manipulation-of-Plot-Windows.html#XREFdelete">delete</a>, <a href="#XREFrmdir">rmdir</a>. </p></dd></dl> <a name="XREFlink"></a><dl> <dt><a name="index-link"></a><em></em> <strong>link</strong> <em><var>old</var> <var>new</var></em></dt> <dt><a name="index-link-1"></a><em>[<var>err</var>, <var>msg</var>] =</em> <strong>link</strong> <em>(<var>old</var>, <var>new</var>)</em></dt> <dd><p>Create a new link (also known as a hard link) to an existing file. </p> <p>If successful, <var>err</var> is 0 and <var>msg</var> is an empty string. Otherwise, <var>err</var> is nonzero and <var>msg</var> contains a system-dependent error message. </p> <p><strong>See also:</strong> <a href="#XREFsymlink">symlink</a>, <a href="#XREFunlink">unlink</a>, <a href="#XREFreadlink">readlink</a>, <a href="#XREFlstat">lstat</a>. </p></dd></dl> <a name="XREFsymlink"></a><dl> <dt><a name="index-symlink"></a><em></em> <strong>symlink</strong> <em><var>old</var> <var>new</var></em></dt> <dt><a name="index-symlink-1"></a><em>[<var>err</var>, <var>msg</var>] =</em> <strong>symlink</strong> <em>(<var>old</var>, <var>new</var>)</em></dt> <dd><p>Create a symbolic link <var>new</var> which contains the string <var>old</var>. </p> <p>If successful, <var>err</var> is 0 and <var>msg</var> is an empty string. Otherwise, <var>err</var> is nonzero and <var>msg</var> contains a system-dependent error message. </p> <p><strong>See also:</strong> <a href="#XREFlink">link</a>, <a href="#XREFunlink">unlink</a>, <a href="#XREFreadlink">readlink</a>, <a href="#XREFlstat">lstat</a>. </p></dd></dl> <a name="XREFreadlink"></a><dl> <dt><a name="index-readlink"></a><em></em> <strong>readlink</strong> <em><var>symlink</var></em></dt> <dt><a name="index-readlink-1"></a><em>[<var>result</var>, <var>err</var>, <var>msg</var>] =</em> <strong>readlink</strong> <em>(<var>symlink</var>)</em></dt> <dd><p>Read the value of the symbolic link <var>symlink</var>. </p> <p>If successful, <var>result</var> contains the contents of the symbolic link <var>symlink</var>, <var>err</var> is 0, and <var>msg</var> is an empty string. Otherwise, <var>err</var> is nonzero and <var>msg</var> contains a system-dependent error message. </p> <p><strong>See also:</strong> <a href="#XREFlstat">lstat</a>, <a href="#XREFsymlink">symlink</a>, <a href="#XREFlink">link</a>, <a href="#XREFunlink">unlink</a>, <a href="Manipulation-of-Plot-Windows.html#XREFdelete">delete</a>. </p></dd></dl> <a name="XREFmkdir"></a><dl> <dt><a name="index-mkdir"></a><em></em> <strong>mkdir</strong> <em><var>dirname</var></em></dt> <dt><a name="index-mkdir-1"></a><em></em> <strong>mkdir</strong> <em><var>parent</var> <var>dirname</var></em></dt> <dt><a name="index-mkdir-2"></a><em></em> <strong>mkdir</strong> <em>(<var>dirname</var>)</em></dt> <dt><a name="index-mkdir-3"></a><em></em> <strong>mkdir</strong> <em>(<var>parent</var>, <var>dirname</var>)</em></dt> <dt><a name="index-mkdir-4"></a><em>[<var>status</var>, <var>msg</var>, <var>msgid</var>] =</em> <strong>mkdir</strong> <em>(…)</em></dt> <dd><p>Create a directory named <var>dirname</var> in the directory <var>parent</var>, creating any intermediate directories if necessary. </p> <p>If <var>dirname</var> is a relative path, and no <var>parent</var> directory is specified, then the present working directory is used. </p> <p>If successful, <var>status</var> is 1, and <var>msg</var> and <var>msgid</var> are empty strings (""). Otherwise, <var>status</var> is 0, <var>msg</var> contains a system-dependent error message, and <var>msgid</var> contains a unique message identifier. </p> <p>When creating a directory permissions will be set to <code>0777 <span class="nolinebreak">-</span> UMASK</code><!-- /@w -->. </p> <p><strong>See also:</strong> <a href="#XREFrmdir">rmdir</a>, <a href="Current-Working-Directory.html#XREFpwd">pwd</a>, <a href="Current-Working-Directory.html#XREFcd">cd</a>, <a href="#XREFumask">umask</a>. </p></dd></dl> <a name="XREFrmdir"></a><dl> <dt><a name="index-rmdir"></a><em></em> <strong>rmdir</strong> <em><var>dir</var></em></dt> <dt><a name="index-rmdir-1"></a><em></em> <strong>rmdir</strong> <em>(<var>dir</var>, "s")</em></dt> <dt><a name="index-rmdir-2"></a><em>[<var>status</var>, <var>msg</var>, <var>msgid</var>] =</em> <strong>rmdir</strong> <em>(…)</em></dt> <dd><p>Remove the directory named <var>dir</var>. </p> <p>If the optional second parameter is supplied with value <code>"s"</code>, recursively remove all subdirectories as well. </p> <p>If successful, <var>status</var> is 1, and <var>msg</var>, <var>msgid</var> are empty character strings (""). Otherwise, <var>status</var> is 0, <var>msg</var> contains a system-dependent error message, and <var>msgid</var> contains a unique message identifier. </p> <p><strong>See also:</strong> <a href="#XREFmkdir">mkdir</a>, <a href="#XREFconfirm_005frecursive_005frmdir">confirm_recursive_rmdir</a>, <a href="Current-Working-Directory.html#XREFpwd">pwd</a>. </p></dd></dl> <a name="XREFconfirm_005frecursive_005frmdir"></a><dl> <dt><a name="index-confirm_005frecursive_005frmdir"></a><em><var>val</var> =</em> <strong>confirm_recursive_rmdir</strong> <em>()</em></dt> <dt><a name="index-confirm_005frecursive_005frmdir-1"></a><em><var>old_val</var> =</em> <strong>confirm_recursive_rmdir</strong> <em>(<var>new_val</var>)</em></dt> <dt><a name="index-confirm_005frecursive_005frmdir-2"></a><em></em> <strong>confirm_recursive_rmdir</strong> <em>(<var>new_val</var>, "local")</em></dt> <dd><p>Query or set the internal variable that controls whether Octave will ask for confirmation before recursively removing a directory tree. </p> <p>When called from inside a function with the <code>"local"</code> option, the variable is changed locally for the function and any subroutines it calls. The original variable value is restored when exiting the function. </p> <p><strong>See also:</strong> <a href="#XREFrmdir">rmdir</a>. </p></dd></dl> <a name="XREFmkfifo"></a><dl> <dt><a name="index-mkfifo"></a><em><var>err</var> =</em> <strong>mkfifo</strong> <em>(<var>name</var>, <var>mode</var>)</em></dt> <dt><a name="index-mkfifo-1"></a><em>[<var>err</var>, <var>msg</var>] =</em> <strong>mkfifo</strong> <em>(<var>name</var>, <var>mode</var>)</em></dt> <dd><p>Create a FIFO special file named <var>name</var> with file mode <var>mode</var>. </p> <p><var>mode</var> is interpreted as an octal number and is subject to umask processing. The final calculated mode is <code><var>mode</var> - <var>umask</var></code>. </p> <p>If successful, <var>err</var> is 0 and <var>msg</var> is an empty string. Otherwise, <var>err</var> is nonzero and <var>msg</var> contains a system-dependent error message. </p> <p><strong>See also:</strong> <a href="Controlling-Subprocesses.html#XREFpipe">pipe</a>, <a href="#XREFumask">umask</a>. </p></dd></dl> <a name="XREFumask"></a><dl> <dt><a name="index-umask"></a><em></em> <strong>umask</strong> <em>(<var>mask</var>)</em></dt> <dd><p>Set the permission mask for file creation. </p> <p>The parameter <var>mask</var> is an integer, interpreted as an octal number. </p> <p>If successful, returns the previous value of the mask (as an integer to be interpreted as an octal number); otherwise an error message is printed. </p> <p>The permission mask is a UNIX concept used when creating new objects on a file system such as files, directories, or named FIFOs. The object to be created has base permissions in an octal number <var>mode</var> which are modified according to the octal value of <var>mask</var>. The final permissions for the new object are <code><var>mode</var> - <var>mask</var></code>. </p> <p><strong>See also:</strong> <a href="Opening-and-Closing-Files.html#XREFfopen">fopen</a>, <a href="#XREFmkdir">mkdir</a>, <a href="#XREFmkfifo">mkfifo</a>. </p></dd></dl> <a name="XREFlstat"></a><a name="XREFstat"></a><dl> <dt><a name="index-stat"></a><em>[<var>info</var>, <var>err</var>, <var>msg</var>] =</em> <strong>stat</strong> <em>(<var>file</var>)</em></dt> <dt><a name="index-stat-1"></a><em>[<var>info</var>, <var>err</var>, <var>msg</var>] =</em> <strong>stat</strong> <em>(<var>fid</var>)</em></dt> <dt><a name="index-lstat"></a><em>[<var>info</var>, <var>err</var>, <var>msg</var>] =</em> <strong>lstat</strong> <em>(<var>file</var>)</em></dt> <dt><a name="index-lstat-1"></a><em>[<var>info</var>, <var>err</var>, <var>msg</var>] =</em> <strong>lstat</strong> <em>(<var>fid</var>)</em></dt> <dd><p>Return a structure <var>info</var> containing the following information about <var>file</var> or file identifier <var>fid</var>. </p> <dl compact="compact"> <dt><code>dev</code></dt> <dd><p>ID of device containing a directory entry for this file. </p> </dd> <dt><code>ino</code></dt> <dd><p>File number of the file. </p> </dd> <dt><code>mode</code></dt> <dd><p>File mode, as an integer. Use the functions <code><span class="nolinebreak">S_ISREG</span></code><!-- /@w -->, <code><span class="nolinebreak">S_ISDIR</span></code><!-- /@w -->, <code><span class="nolinebreak">S_ISCHR</span></code><!-- /@w -->, <code><span class="nolinebreak">S_ISBLK</span></code><!-- /@w -->, <code><span class="nolinebreak">S_ISFIFO</span></code><!-- /@w -->, <code><span class="nolinebreak">S_ISLNK</span></code><!-- /@w -->, or <code><span class="nolinebreak">S_ISSOCK</span></code><!-- /@w --> to extract information from this value. </p> </dd> <dt><code>modestr</code></dt> <dd><p>File mode, as a string of ten letters or dashes as would be returned by <kbd>ls -l</kbd>. </p> </dd> <dt><code>nlink</code></dt> <dd><p>Number of links. </p> </dd> <dt><code>uid</code></dt> <dd><p>User ID of file’s owner. </p> </dd> <dt><code>gid</code></dt> <dd><p>Group ID of file’s group. </p> </dd> <dt><code>rdev</code></dt> <dd><p>ID of device for block or character special files. </p> </dd> <dt><code>size</code></dt> <dd><p>Size in bytes. </p> </dd> <dt><code>atime</code></dt> <dd><p>Time of last access in the same form as time values returned from <code>time</code>. See <a href="Timing-Utilities.html#Timing-Utilities">Timing Utilities</a>. </p> </dd> <dt><code>mtime</code></dt> <dd><p>Time of last modification in the same form as time values returned from <code>time</code>. See <a href="Timing-Utilities.html#Timing-Utilities">Timing Utilities</a>. </p> </dd> <dt><code>ctime</code></dt> <dd><p>Time of last file status change in the same form as time values returned from <code>time</code>. See <a href="Timing-Utilities.html#Timing-Utilities">Timing Utilities</a>. </p> </dd> <dt><code>blksize</code></dt> <dd><p>Size of blocks in the file. </p> </dd> <dt><code>blocks</code></dt> <dd><p>Number of blocks allocated for file. </p></dd> </dl> <p>If the call is successful <var>err</var> is 0 and <var>msg</var> is an empty string. If the file does not exist, or some other error occurs, <var>info</var> is an empty matrix, <var>err</var> is -1, and <var>msg</var> contains the corresponding system error message. </p> <p>If <var>file</var> is a symbolic link, <code>stat</code> will return information about the actual file that is referenced by the link. Use <code>lstat</code> if you want information about the symbolic link itself. </p> <p>For example: </p> <div class="example"> <pre class="example">[info, err, msg] = stat ("/vmlinuz") ⇒ info = { atime = 855399756 rdev = 0 ctime = 847219094 uid = 0 size = 389218 blksize = 4096 mtime = 847219094 gid = 6 nlink = 1 blocks = 768 mode = -rw-r--r-- modestr = -rw-r--r-- ino = 9316 dev = 2049 } ⇒ err = 0 ⇒ msg = </pre></div> <p><strong>See also:</strong> <a href="#XREFlstat">lstat</a>, <a href="Current-Working-Directory.html#XREFls">ls</a>, <a href="Current-Working-Directory.html#XREFdir">dir</a>, <a href="#XREFisfile">isfile</a>, <a href="#XREFisfolder">isfolder</a>. </p></dd></dl> <a name="XREFS_005fISBLK"></a><dl> <dt><a name="index-S_005fISBLK"></a><em></em> <strong>S_ISBLK</strong> <em>(<var>mode</var>)</em></dt> <dd><p>Return true if <var>mode</var> corresponds to a block device. </p> <p>The value of <var>mode</var> is assumed to be returned from a call to <code>stat</code>. </p> <p><strong>See also:</strong> <a href="#XREFstat">stat</a>, <a href="#XREFlstat">lstat</a>. </p></dd></dl> <a name="XREFS_005fISCHR"></a><dl> <dt><a name="index-S_005fISCHR"></a><em></em> <strong>S_ISCHR</strong> <em>(<var>mode</var>)</em></dt> <dd><p>Return true if <var>mode</var> corresponds to a character device. </p> <p>The value of <var>mode</var> is assumed to be returned from a call to <code>stat</code>. </p> <p><strong>See also:</strong> <a href="#XREFstat">stat</a>, <a href="#XREFlstat">lstat</a>. </p></dd></dl> <a name="XREFS_005fISDIR"></a><dl> <dt><a name="index-S_005fISDIR"></a><em></em> <strong>S_ISDIR</strong> <em>(<var>mode</var>)</em></dt> <dd><p>Return true if <var>mode</var> corresponds to a directory. </p> <p>The value of <var>mode</var> is assumed to be returned from a call to <code>stat</code>. </p> <p><strong>See also:</strong> <a href="#XREFstat">stat</a>, <a href="#XREFlstat">lstat</a>. </p></dd></dl> <a name="XREFS_005fISFIFO"></a><dl> <dt><a name="index-S_005fISFIFO"></a><em></em> <strong>S_ISFIFO</strong> <em>(<var>mode</var>)</em></dt> <dd><p>Return true if <var>mode</var> corresponds to a fifo. </p> <p>The value of <var>mode</var> is assumed to be returned from a call to <code>stat</code>. </p> <p><strong>See also:</strong> <a href="#XREFstat">stat</a>, <a href="#XREFlstat">lstat</a>. </p></dd></dl> <a name="XREFS_005fISLNK"></a><dl> <dt><a name="index-S_005fISLNK"></a><em></em> <strong>S_ISLNK</strong> <em>(<var>mode</var>)</em></dt> <dd><p>Return true if <var>mode</var> corresponds to a symbolic link. </p> <p>The value of <var>mode</var> is assumed to be returned from a call to <code>stat</code>. </p> <p><strong>See also:</strong> <a href="#XREFstat">stat</a>, <a href="#XREFlstat">lstat</a>. </p></dd></dl> <a name="XREFS_005fISREG"></a><dl> <dt><a name="index-S_005fISREG"></a><em></em> <strong>S_ISREG</strong> <em>(<var>mode</var>)</em></dt> <dd><p>Return true if <var>mode</var> corresponds to a regular file. </p> <p>The value of <var>mode</var> is assumed to be returned from a call to <code>stat</code>. </p> <p><strong>See also:</strong> <a href="#XREFstat">stat</a>, <a href="#XREFlstat">lstat</a>. </p></dd></dl> <a name="XREFS_005fISSOCK"></a><dl> <dt><a name="index-S_005fISSOCK"></a><em></em> <strong>S_ISSOCK</strong> <em>(<var>mode</var>)</em></dt> <dd><p>Return true if <var>mode</var> corresponds to a socket. </p> <p>The value of <var>mode</var> is assumed to be returned from a call to <code>stat</code>. </p> <p><strong>See also:</strong> <a href="#XREFstat">stat</a>, <a href="#XREFlstat">lstat</a>. </p></dd></dl> <a name="XREFfileattrib"></a><dl> <dt><a name="index-fileattrib"></a><em></em> <strong>fileattrib</strong> <em>(<var>file</var>)</em></dt> <dt><a name="index-fileattrib-1"></a><em></em> <strong>fileattrib</strong> <em>()</em></dt> <dt><a name="index-fileattrib-2"></a><em>[<var>status</var>, <var>msg</var>, <var>msgid</var>] =</em> <strong>fileattrib</strong> <em>(…)</em></dt> <dd><p>Return information about <var>file</var>. </p> <p>If successful, <var>status</var> is 1 and <var>msg</var> is a structure with the following fields: </p> <dl compact="compact"> <dt><code>Name</code></dt> <dd><p>Full name of <var>file</var>. </p> </dd> <dt><code>archive</code></dt> <dd><p>True if <var>file</var> is an archive (Windows). </p> </dd> <dt><code>system</code></dt> <dd><p>True if <var>file</var> is a system file (Windows). </p> </dd> <dt><code>hidden</code></dt> <dd><p>True if <var>file</var> is a hidden file (Windows). </p> </dd> <dt><code>directory</code></dt> <dd><p>True if <var>file</var> is a directory. </p> </dd> <dt><code>UserRead</code></dt> <dt><code>GroupRead</code></dt> <dt><code>OtherRead</code></dt> <dd><p>True if the user (group; other users) has read permission for <var>file</var>. </p> </dd> <dt><code>UserWrite</code></dt> <dt><code>GroupWrite</code></dt> <dt><code>OtherWrite</code></dt> <dd><p>True if the user (group; other users) has write permission for <var>file</var>. </p> </dd> <dt><code>UserExecute</code></dt> <dt><code>GroupExecute</code></dt> <dt><code>OtherExecute</code></dt> <dd><p>True if the user (group; other users) has execute permission for <var>file</var>. </p></dd> </dl> <p>If an attribute does not apply (i.e., archive on a Unix system) then the field is set to NaN. </p> <p>If <code>attrib</code> fails, <var>msg</var> is a non-empty string containing an error message and <var>msg_id</var> is the non-empty string <code>"fileattrib"</code>. </p> <p>With no input arguments, return information about the current directory. </p> <p>If <var>file</var> contains globbing characters, return information about all the matching files. </p> <p><strong>See also:</strong> <a href="#XREFglob">glob</a>. </p></dd></dl> <a name="XREFisfile"></a><dl> <dt><a name="index-isfile"></a><em><var>tf</var> =</em> <strong>isfile</strong> <em>(<var>f</var>)</em></dt> <dd><p>Return true if <var>f</var> is a regular file and false otherwise. </p> <p>If <var>f</var> is a cell array of strings, <var>tf</var> is a logical array of the same size. </p> <p><strong>See also:</strong> <a href="#XREFisfolder">isfolder</a>, <a href="Status-of-Variables.html#XREFexist">exist</a>, <a href="#XREFstat">stat</a>, <a href="#XREFis_005fabsolute_005ffilename">is_absolute_filename</a>, <a href="#XREFis_005frooted_005frelative_005ffilename">is_rooted_relative_filename</a>. </p></dd></dl> <a name="XREFisdir"></a><dl> <dt><a name="index-isdir"></a><em></em> <strong>isdir</strong> <em>(<var>f</var>)</em></dt> <dd> <p>This function is not recommended. Use <code>isfolder</code> or <code>file_in_loadpath</code> instead. </p> <p>Return true if <var>f</var> is a directory and false otherwise. </p> <p>Compatibility Note: The <small>MATLAB</small> function of the same name will also search for <var>f</var> in the load path directories. To emulate this behavior use </p> <div class="example"> <pre class="example"><var>tf</var> = ! isempty (file_in_loadpath (<var>f</var>)) </pre></div> <p><strong>See also:</strong> <a href="#XREFisfolder">isfolder</a>, <a href="Manipulating-the-Load-Path.html#XREFfile_005fin_005floadpath">file_in_loadpath</a>, <a href="Status-of-Variables.html#XREFexist">exist</a>, <a href="#XREFstat">stat</a>, <a href="#XREFis_005fabsolute_005ffilename">is_absolute_filename</a>, <a href="#XREFis_005frooted_005frelative_005ffilename">is_rooted_relative_filename</a>. </p></dd></dl> <a name="XREFisfolder"></a><dl> <dt><a name="index-isfolder"></a><em></em> <strong>isfolder</strong> <em>(<var>f</var>)</em></dt> <dt><a name="index-isfolder-1"></a><em><var>tf</var> =</em> <strong>isfolder</strong> <em>(<var>f</var>)</em></dt> <dd><p>Return true if <var>f</var> is a directory and false otherwise. </p> <p>If <var>f</var> is a cell array of strings, <var>tf</var> is a logical array of the same size. </p> <p><strong>See also:</strong> <a href="#XREFisfile">isfile</a>, <a href="Status-of-Variables.html#XREFexist">exist</a>, <a href="#XREFstat">stat</a>, <a href="#XREFis_005fabsolute_005ffilename">is_absolute_filename</a>, <a href="#XREFis_005frooted_005frelative_005ffilename">is_rooted_relative_filename</a>. </p></dd></dl> <a name="XREFreaddir"></a><dl> <dt><a name="index-readdir"></a><em><var>files</var> =</em> <strong>readdir</strong> <em>(<var>dir</var>)</em></dt> <dt><a name="index-readdir-1"></a><em>[<var>files</var>, <var>err</var>, <var>msg</var>] =</em> <strong>readdir</strong> <em>(<var>dir</var>)</em></dt> <dd><p>Return the names of files in the directory <var>dir</var> as a cell array of strings. </p> <p>If an error occurs, return an empty cell array in <var>files</var>. If successful, <var>err</var> is 0 and <var>msg</var> is an empty string. Otherwise, <var>err</var> is nonzero and <var>msg</var> contains a system-dependent error message. </p> <p><strong>See also:</strong> <a href="Current-Working-Directory.html#XREFls">ls</a>, <a href="Current-Working-Directory.html#XREFdir">dir</a>, <a href="#XREFglob">glob</a>, <a href="Status-of-Variables.html#XREFwhat">what</a>. </p></dd></dl> <a name="XREFglob"></a><dl> <dt><a name="index-glob"></a><em></em> <strong>glob</strong> <em>(<var>pattern</var>)</em></dt> <dd><p>Given an array of pattern strings (as a char array or a cell array) in <var>pattern</var>, return a cell array of filenames that match any of them, or an empty cell array if no patterns match. </p> <p>The pattern strings are interpreted as filename globbing patterns (as they are used by Unix shells). </p> <p>Within a pattern </p> <dl compact="compact"> <dt><code>*</code></dt> <dd><p>matches any string, including the null string, </p> </dd> <dt><code>?</code></dt> <dd><p>matches any single character, and </p> </dd> <dt><code>[…]</code></dt> <dd><p>matches any of the enclosed characters. </p></dd> </dl> <p>Tilde expansion is performed on each of the patterns before looking for matching filenames. For example: </p> <div class="example"> <pre class="example">ls ⇒ file1 file2 file3 myfile1 myfile1b glob ("*file1") ⇒ { [1,1] = file1 [2,1] = myfile1 } glob ("myfile?") ⇒ { [1,1] = myfile1 } glob ("file[12]") ⇒ { [1,1] = file1 [2,1] = file2 } </pre></div> <p><strong>See also:</strong> <a href="Current-Working-Directory.html#XREFls">ls</a>, <a href="Current-Working-Directory.html#XREFdir">dir</a>, <a href="#XREFreaddir">readdir</a>, <a href="Status-of-Variables.html#XREFwhat">what</a>. </p></dd></dl> <a name="XREFfile_005fin_005fpath"></a><dl> <dt><a name="index-file_005fin_005fpath"></a><em></em> <strong>file_in_path</strong> <em>(<var>path</var>, <var>file</var>)</em></dt> <dt><a name="index-file_005fin_005fpath-1"></a><em></em> <strong>file_in_path</strong> <em>(<var>path</var>, <var>file</var>, "all")</em></dt> <dd><p>Return the absolute name of <var>file</var> if it can be found in <var>path</var>. </p> <p>The value of <var>path</var> should be a colon-separated list of directories in the format described for <code>path</code>. If no file is found, return an empty character string. For example: </p> <div class="example"> <pre class="example">file_in_path (EXEC_PATH, "sh") ⇒ "/bin/sh" </pre></div> <p>If the second argument is a cell array of strings, search each directory of the path for element of the cell array and return the first that matches. </p> <p>If the third optional argument <code>"all"</code> is supplied, return a cell array containing the list of all files that have the same name in the path. If no files are found, return an empty cell array. </p> <p><strong>See also:</strong> <a href="Manipulating-the-Load-Path.html#XREFfile_005fin_005floadpath">file_in_loadpath</a>, <a href="Manipulating-the-Load-Path.html#XREFdir_005fin_005floadpath">dir_in_loadpath</a>, <a href="Manipulating-the-Load-Path.html#XREFpath">path</a>. </p></dd></dl> <a name="XREFfilesep"></a><dl> <dt><a name="index-filesep"></a><em></em> <strong>filesep</strong> <em>()</em></dt> <dt><a name="index-filesep-1"></a><em></em> <strong>filesep</strong> <em>("all")</em></dt> <dd><p>Return the system-dependent character used to separate directory names. </p> <p>If <code>"all"</code> is given, the function returns all valid file separators in the form of a string. The list of file separators is system-dependent. It is ‘<samp>/</samp>’ (forward slash) under UNIX or Mac OS X<!-- /@w -->, ‘<samp>/</samp>’ and ‘<samp>\</samp>’ (forward and backward slashes) under Windows. </p> <p><strong>See also:</strong> <a href="Manipulating-the-Load-Path.html#XREFpathsep">pathsep</a>. </p></dd></dl> <a name="XREFfileparts"></a><dl> <dt><a name="index-fileparts"></a><em>[<var>dir</var>, <var>name</var>, <var>ext</var>] =</em> <strong>fileparts</strong> <em>(<var>filename</var>)</em></dt> <dd><p>Return the directory, name, and extension components of <var>filename</var>. </p> <p>The input <var>filename</var> is a string which is parsed. There is no attempt to check whether the filename or directory specified actually exists. </p> <p><strong>See also:</strong> <a href="#XREFfullfile">fullfile</a>, <a href="#XREFfilesep">filesep</a>. </p></dd></dl> <a name="XREFfullfile"></a><dl> <dt><a name="index-fullfile"></a><em><var>filename</var> =</em> <strong>fullfile</strong> <em>(<var>dir1</var>, <var>dir2</var>, …, <var>file</var>)</em></dt> <dt><a name="index-fullfile-1"></a><em><var>filenames</var> =</em> <strong>fullfile</strong> <em>(…, <var>files</var>)</em></dt> <dd><p>Build complete filename from separate parts. </p> <p>Joins any number of path components intelligently. The return value is the concatenation of each component with exactly one file separator between each non empty part and at most one leading and/or trailing file separator. </p> <p>If the last component part is a cell array, returns a cell array of filepaths, one for each element in the last component, e.g.: </p> <div class="example"> <pre class="example">fullfile ("/home/username", "data", {"f1.csv", "f2.csv", "f3.csv"}) ⇒ { [1,1] = /home/username/data/f1.csv [1,2] = /home/username/data/f2.csv [1,3] = /home/username/data/f3.csv } </pre></div> <p>On Windows systems, while forward slash file separators do work, they are replaced by backslashes; in addition drive letters are stripped of leading file separators to obtain a valid file path. </p> <p>Note: <code>fullfile</code> does not perform any validation of the resulting full filename. </p> <p><strong>See also:</strong> <a href="#XREFfileparts">fileparts</a>, <a href="#XREFfilesep">filesep</a>. </p></dd></dl> <a name="XREFtilde_005fexpand"></a><dl> <dt><a name="index-tilde_005fexpand"></a><em></em> <strong>tilde_expand</strong> <em>(<var>string</var>)</em></dt> <dt><a name="index-tilde_005fexpand-1"></a><em></em> <strong>tilde_expand</strong> <em>(<var>cellstr</var>)</em></dt> <dd><p>Perform tilde expansion on <var>string</var>. </p> <p>If <var>string</var> begins with a tilde character, (‘<samp>~</samp>’), all of the characters preceding the first slash (or all characters, if there is no slash) are treated as a possible user name, and the tilde and the following characters up to the slash are replaced by the home directory of the named user. If the tilde is followed immediately by a slash, the tilde is replaced by the home directory of the user running Octave. </p> <p>If the input is a cell array of strings <var>cellstr</var> then tilde expansion is performed on each string element. </p> <p>Examples: </p> <div class="example"> <pre class="example">tilde_expand ("~joeuser/bin") ⇒ "/home/joeuser/bin" tilde_expand ("~/bin") ⇒ "/home/jwe/bin" </pre></div> </dd></dl> <a name="XREFcanonicalize_005ffile_005fname"></a><dl> <dt><a name="index-canonicalize_005ffile_005fname"></a><em>[<var>cname</var>, <var>status</var>, <var>msg</var>] =</em> <strong>canonicalize_file_name</strong> <em>(<var>fname</var>)</em></dt> <dd><p>Return the canonical name of file <var>fname</var>. </p> <p>If the file does not exist the empty string ("") is returned. </p> <p><strong>See also:</strong> <a href="#XREFmake_005fabsolute_005ffilename">make_absolute_filename</a>, <a href="#XREFis_005fabsolute_005ffilename">is_absolute_filename</a>, <a href="#XREFis_005frooted_005frelative_005ffilename">is_rooted_relative_filename</a>. </p></dd></dl> <a name="XREFmake_005fabsolute_005ffilename"></a><dl> <dt><a name="index-make_005fabsolute_005ffilename"></a><em></em> <strong>make_absolute_filename</strong> <em>(<var>file</var>)</em></dt> <dd><p>Return the full name of <var>file</var> beginning from the root of the file system. </p> <p>No check is done for the existence of <var>file</var>. </p> <p><strong>See also:</strong> <a href="#XREFcanonicalize_005ffile_005fname">canonicalize_file_name</a>, <a href="#XREFis_005fabsolute_005ffilename">is_absolute_filename</a>, <a href="#XREFis_005frooted_005frelative_005ffilename">is_rooted_relative_filename</a>, <a href="#XREFisfolder">isfolder</a>. </p></dd></dl> <a name="XREFis_005fabsolute_005ffilename"></a><dl> <dt><a name="index-is_005fabsolute_005ffilename"></a><em></em> <strong>is_absolute_filename</strong> <em>(<var>file</var>)</em></dt> <dd><p>Return true if <var>file</var> is an absolute filename. </p> <p><strong>See also:</strong> <a href="#XREFis_005frooted_005frelative_005ffilename">is_rooted_relative_filename</a>, <a href="#XREFmake_005fabsolute_005ffilename">make_absolute_filename</a>, <a href="#XREFisfolder">isfolder</a>. </p></dd></dl> <a name="XREFis_005frooted_005frelative_005ffilename"></a><dl> <dt><a name="index-is_005frooted_005frelative_005ffilename"></a><em></em> <strong>is_rooted_relative_filename</strong> <em>(<var>file</var>)</em></dt> <dd><p>Return true if <var>file</var> is a rooted-relative filename. </p> <p><strong>See also:</strong> <a href="#XREFis_005fabsolute_005ffilename">is_absolute_filename</a>, <a href="#XREFmake_005fabsolute_005ffilename">make_absolute_filename</a>, <a href="#XREFisfolder">isfolder</a>. </p></dd></dl> <a name="XREFrecycle"></a><dl> <dt><a name="index-recycle"></a><em><var>val</var> =</em> <strong>recycle</strong> <em>()</em></dt> <dt><a name="index-recycle-1"></a><em><var>old_val</var> =</em> <strong>recycle</strong> <em>(<var>new_val</var>)</em></dt> <dd><p>Query or set the preference for recycling deleted files. </p> <p>When recycling is enabled, commands which would permanently erase files instead move them to a temporary location (such as the directory labeled Trash). </p> <p>Programming Note: This function is provided for <small>MATLAB</small> compatibility, but recycling is not implemented in Octave. To help avoid accidental data loss an error will be raised if an attempt is made to enable file recycling. </p> <p><strong>See also:</strong> <a href="Manipulation-of-Plot-Windows.html#XREFdelete">delete</a>, <a href="#XREFrmdir">rmdir</a>. </p></dd></dl> <hr> <div class="header"> <p> Next: <a href="File-Archiving-Utilities.html#File-Archiving-Utilities" accesskey="n" rel="next">File Archiving Utilities</a>, Previous: <a href="Timing-Utilities.html#Timing-Utilities" accesskey="p" rel="prev">Timing Utilities</a>, Up: <a href="System-Utilities.html#System-Utilities" accesskey="u" rel="up">System Utilities</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p> </div> </body> </html>