octave: Manipulating the Load Path
11.9.1 Manipulating the Load Path
---------------------------------
When a function is called, Octave searches a list of directories for a
file that contains the function declaration. This list of directories
is known as the load path. By default the load path contains a list of
directories distributed with Octave plus the current working directory.
To see your current load path call the ‘path’ function without any input
or output arguments.
It is possible to add or remove directories to or from the load path
using ‘addpath’ and ‘rmpath’. As an example, the following code adds
‘~/Octave’ to the load path.
addpath ("~/Octave")
After this the directory ‘~/Octave’ will be searched for functions.
-- : addpath (DIR1, ...)
-- : addpath (DIR1, ..., OPTION)
Add named directories to the function search path.
If OPTION is "-begin" or 0 (the default), prepend the directory
name to the current path. If OPTION is "-end" or 1, append the
directory name to the current path. Directories added to the path
must exist.
In addition to accepting individual directory arguments, lists of
directory names separated by ‘pathsep’ are also accepted. For
example:
addpath ("dir1:/dir2:~/dir3")
For each directory that is added, and that was not already in the
path, ‘addpath’ checks for the existence of a file named ‘PKG_ADD’
(note lack of .m extension) and runs it if it exists.
DONTPRINTYET See also: path XREFpath, rmpath XREFrmpath, *noteDONTPRINTYET DONTPRINTYET See also: path XREFpath, rmpath XREFrmpath,
genpath XREFgenpath, pathdef XREFpathdef, *notesavepath:
DONTPRINTYET DONTPRINTYET See also: path XREFpath, rmpath XREFrmpath,
genpath XREFgenpath, pathdef XREFpathdef, savepath
XREFsavepath, pathsep XREFpathsep.
-- : genpath (DIR)
-- : genpath (DIR, SKIP, ...)
Return a path constructed from DIR and all its subdirectories.
If additional string parameters are given, the resulting path will
exclude directories with those names.
-- : rmpath (DIR1, ...)
Remove DIR1, ... from the current function search path.
In addition to accepting individual directory arguments, lists of
directory names separated by ‘pathsep’ are also accepted. For
example:
rmpath ("dir1:/dir2:~/dir3")
For each directory that is removed, ‘rmpath’ checks for the
existence of a file named ‘PKG_DEL’ (note lack of .m extension) and
runs it if it exists.
DONTPRINTYET See also: path XREFpath, addpath XREFaddpath, *noteDONTPRINTYET DONTPRINTYET See also: path XREFpath, addpath XREFaddpath,
genpath XREFgenpath, pathdef XREFpathdef, *notesavepath:
DONTPRINTYET DONTPRINTYET See also: path XREFpath, addpath XREFaddpath,
genpath XREFgenpath, pathdef XREFpathdef, savepath
XREFsavepath, pathsep XREFpathsep.
-- : savepath ()
-- : savepath (FILE)
-- : STATUS = savepath (...)
Save the unique portion of the current function search path that is
not set during Octave’s initialization process to FILE.
If FILE is omitted, Octave looks in the current directory for a
project-specific ‘.octaverc’ file in which to save the path
information. If no such file is present then the user’s
configuration file ‘~/.octaverc’ is used.
If successful, ‘savepath’ returns 0.
The ‘savepath’ function makes it simple to customize a user’s
configuration file to restore the working paths necessary for a
particular instance of Octave. Assuming no filename is specified,
Octave will automatically restore the saved directory paths from
the appropriate ‘.octaverc’ file when starting up. If a filename
has been specified then the paths may be restored manually by
calling ‘source FILE’.
DONTPRINTYET See also: path XREFpath, addpath XREFaddpath, *noteDONTPRINTYET DONTPRINTYET See also: path XREFpath, addpath XREFaddpath,
rmpath XREFrmpath, genpath XREFgenpath, *notepathdef:
DONTPRINTYET DONTPRINTYET See also: path XREFpath, addpath XREFaddpath,
rmpath XREFrmpath, genpath XREFgenpath, pathdef
XREFpathdef.
-- : path ()
-- : STR = path ()
-- : STR = path (PATH1, ...)
Modify or display Octave’s load path.
If NARGIN and NARGOUT are zero, display the elements of Octave’s
load path in an easy to read format.
If NARGIN is zero and nargout is greater than zero, return the
current load path.
If NARGIN is greater than zero, concatenate the arguments,
separating them with ‘pathsep’. Set the internal search path to
the result and return it.
No checks are made for duplicate elements.
See also: addpath XREFaddpath, rmpath XREFrmpath,
DONTPRINTYET genpath XREFgenpath, pathdef XREFpathdef, *noteDONTPRINTYET genpath XREFgenpath, pathdef XREFpathdef,
savepath XREFsavepath, pathsep XREFpathsep.
-- : VAL = pathdef ()
Return the default path for Octave.
The path information is extracted from one of four sources. The
possible sources, in order of preference, are:
1. ‘.octaverc’
2. ‘~/.octaverc’
3. ‘<OCTAVE_HOME>/.../<version>/m/startup/octaverc’
4. Octave’s path prior to changes by any octaverc file.
DONTPRINTYET See also: path XREFpath, addpath XREFaddpath, *noteDONTPRINTYET DONTPRINTYET See also: path XREFpath, addpath XREFaddpath,
rmpath XREFrmpath, genpath XREFgenpath, *notesavepath:
DONTPRINTYET DONTPRINTYET See also: path XREFpath, addpath XREFaddpath,
rmpath XREFrmpath, genpath XREFgenpath, savepath
XREFsavepath.
-- : VAL = pathsep ()
-- : OLD_VAL = pathsep (NEW_VAL)
Query or set the character used to separate directories in a path.
See also: filesep XREFfilesep.
-- : rehash ()
Reinitialize Octave’s load path directory cache.
-- : file_in_loadpath (FILE)
-- : file_in_loadpath (FILE, "all")
Return the absolute name of FILE if it can be found in the list of
directories specified by ‘path’.
If no file is found, return an empty character string.
If the first argument is a cell array of strings, search each
directory of the loadpath for element of the cell array and return
the first that matches.
If the second optional argument "all" 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.
DONTPRINTYET See also: file_in_path XREFfile_in_path, *noteDONTPRINTYET See also: file_in_path XREFfile_in_path,
dir_in_loadpath XREFdir_in_loadpath, path XREFpath.
-- : restoredefaultpath (...)
Restore Octave’s path to its initial state at startup.
DONTPRINTYET See also: path XREFpath, addpath XREFaddpath, *noteDONTPRINTYET DONTPRINTYET See also: path XREFpath, addpath XREFaddpath,
rmpath XREFrmpath, genpath XREFgenpath, *notepathdef:
DONTPRINTYET DONTPRINTYET DONTPRINTYET See also: path XREFpath, addpath XREFaddpath,
rmpath XREFrmpath, genpath XREFgenpath, pathdef
XREFpathdef, savepath XREFsavepath, *notepathsep:
DONTPRINTYET DONTPRINTYET DONTPRINTYET See also: path XREFpath, addpath XREFaddpath,
rmpath XREFrmpath, genpath XREFgenpath, pathdef
XREFpathdef, savepath XREFsavepath, pathsep
XREFpathsep.
-- : command_line_path (...)
Return the command line path variable.
DONTPRINTYET See also: path XREFpath, addpath XREFaddpath, *noteDONTPRINTYET DONTPRINTYET See also: path XREFpath, addpath XREFaddpath,
rmpath XREFrmpath, genpath XREFgenpath, *notepathdef:
DONTPRINTYET DONTPRINTYET DONTPRINTYET See also: path XREFpath, addpath XREFaddpath,
rmpath XREFrmpath, genpath XREFgenpath, pathdef
XREFpathdef, savepath XREFsavepath, *notepathsep:
DONTPRINTYET DONTPRINTYET DONTPRINTYET See also: path XREFpath, addpath XREFaddpath,
rmpath XREFrmpath, genpath XREFgenpath, pathdef
XREFpathdef, savepath XREFsavepath, pathsep
XREFpathsep.
-- : dir_in_loadpath (DIR)
-- : dir_in_loadpath (DIR, "all")
Return the full name of the path element matching DIR.
The match is performed at the end of each path element. For
example, if DIR is "foo/bar", it matches the path element
"/some/dir/foo/bar", but not "/some/dir/foo/bar/baz"
"/some/dir/allfoo/bar".
If the optional second argument is supplied, return a cell array
containing all name matches rather than just the first.
DONTPRINTYET See also: file_in_path XREFfile_in_path, *noteDONTPRINTYET See also: file_in_path XREFfile_in_path,
file_in_loadpath XREFfile_in_loadpath, path XREFpath.