Octave includes the following functions for renaming and deleting files creating deleting, and reading directories, and for getting information about the status of files.
[err msg] = rename (old, new) | Built-in Function |
Change the name of file old to new.
If successful err is 0 and msg is an empty string. Otherwise err is nonzero and msg contains a system-dependent error message. |
[err msg] = link (old, new) | Built-in Function |
Create a new link (also known as a hard link) to an existing file.
If successful err is 0 and msg is an empty string. Otherwise err is nonzero and msg contains a system-dependent error message. |
[err msg] = symlink (old, new) | Built-in Function |
Create a symbolic link new which contains the string old.
If successful err is 0 and msg is an empty string. Otherwise err is nonzero and msg contains a system-dependent error message. |
[result err, msg] = readlink (symlink) | Built-in Function |
Read the value of the symbolic link symlink.
If successful result contains the contents of the symbolic link symlink err is 0 and msg is an empty string. Otherwise err is nonzero and msg contains a system-dependent error message. |
[err msg] = unlink (file) | Built-in Function |
Delete the file named file.
If successful err is 0 and msg is an empty string. Otherwise err is nonzero and msg contains a system-dependent error message. |
[files err, msg] = readdir (dir) | Built-in Function |
Return names of the files in the directory dir as a cell array of
strings. If an error occurs return an empty cell array in files.
If successful err is 0 and msg is an empty string. Otherwise err is nonzero and msg contains a system-dependent error message. |
[err msg] = mkdir (dir) | Built-in Function |
Create a directory named dir.
If successful err is 0 and msg is an empty string. Otherwise err is nonzero and msg contains a system-dependent error message. |
[err msg] = rmdir (dir) | Built-in Function |
Remove the directory named dir.
If successful err is 0 and msg is an empty string. Otherwise err is nonzero and msg contains a system-dependent error message. |
[err msg] = mkfifo (name, mode) | Built-in Function |
Create a fifo special file named name with file mode mode
If successful err is 0 and msg is an empty string. Otherwise err is nonzero and msg contains a system-dependent error message. |
umask (mask) | Built-in Function |
Set the permission mask for file creation. The parameter mask is an integer interpreted as an octal number. 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. |
[info err, msg] = stat (file) | Built-in Function |
[info err, msg] = lstat (file) | Built-in Function |
Return a structure s containing the following information about
file.
If the call is successful err is 0 and msg is an empty string. If the file does not exist or some other error occurs, s is an empty matrix err is -1, and msg contains the corresponding system error message. If file is a symbolic link For example [s err, msg] = stat ("/vmlinuz") => s = { atime = 855399756 rdev = 0 ctime = 847219094 uid = 0 size = 389218 blksize = 4096 mtime = 847219094 gid = 6 nlink = 1 blocks = 768 modestr = -rw-r--r-- ino = 9316 dev = 2049 } => err = 0 => msg = |
glob (pattern) | Built-in Function |
Given an array of strings in pattern return a cell array of file
names that match any of them or an empty cell array if no patterns match.
Tilde expansion is performed on each of the patterns before looking for
matching file names. For example
glob ("/vm*") => "/vmlinuz" |
fnmatch (pattern string) | Built-in Function |
Return 1 or zero for each element of string that matches any of
the elements of the string array pattern using the rules of
filename pattern matching. For example
fnmatch ("a*b" ["ab"; "axyzb"; "xyzab"]) => [ 1; 1; 0 ] |
file_in_path (path file) | Built-in Function |
file_in_path (path file, "all") | Built-in Function |
Return the absolute name name of file if it can be found in
path. The value of path should be a colon-separated list of
directories in the format described for the built-in variable
LOADPATH . If no file is found return an empty matrix.
For example
file_in_path (LOADPATH "nargchk.m") => "/usr/local/share/octave/2.0/m/general/nargchk.m" If the second argument is a cell array of of strings search each directory of the path for element of the cell array and return the first that matches. If the third optional argument |
tilde_expand (string) | Built-in Function |
Performs tilde expansion on string. If string begins with a
tilde character (~ ), 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. For example
tilde_expand ("~joeuser/bin") => "/home/joeuser/bin" tilde_expand ("~/bin") => "/home/jwe/bin" |