FileTools - Maple Programming Help

Home : Support : Online Help : Programming : Input and Output : File Manipulation : FileTools : FileTools/SplitPath

FileTools

 SplitPath
 split file path into components
 JoinPath
 join components into file path

 Calling Sequence SplitPath(filepath, opts) JoinPath(components, opts)

Parameters

 filepath - string; file path, relative or absolute components - list of strings; components of a file path, relative or absolute opts - options as described below

Options

 • platform = one of "unix", "windows", or auto.
 The platform option specifies the operating system conventions to use when splitting or joining paths.  The default value, auto, uses the conventions of the current system.
 • base = one of bindir, datadir, homedir, mapledir, tempdir, toolboxdir, worksheetdir.
 The base option specifies a base directory. The parameter components will be interpreted as a relative path under this directory. For the meaning of each of these symbols, see kernelopts or interface. This option is only supported for JoinPath.

Description

 • The SplitPath command splits a file path into a list of its path components. The JoinPath(components) command joins a list of path components into a file path appropriate for the host operating system.
 • SplitPath("SomeDir/SomeFile") returns ["SomeDir", "SomeFile"] and JoinPath(["SomeDir", "SomeFile"]) returns either "SomeDir/SomeFile" (on MacOS and UNIX) or "SomeDir\SomeFile" (on Windows).
 • On Windows, SplitPath(filepath) handles paths corresponding to file shares specially, keeping the server and share name together.  For example, SplitPath("\\SERVER\Share\SomeDir") returns ["\\SERVER\Share", "Somedir"].
 • SplitPath interprets either a slash (/) or backslash (\) character as a delimiter. JoinPath(components) joins its components together using a delimiter specific to the host operating system.
 • Neither command checks that the input corresponds to an existing file on disk or performs any disk input/output.

Examples

 > FileTools:-SplitPath( "C:\\Program Files\\Microsoft Office" );
 $\left[{"C:"}{,}{"Program Files"}{,}{"Microsoft Office"}\right]$ (1)
 > FileTools:-JoinPath( ["C:", "Program Files", "Microsoft Office"], platform = "windows" );
 ${"C:\Program Files\Microsoft Office"}$ (2)
 > FileTools:-JoinPath( ["DirectoryA", "Subdirectory", "MyFile.txt"] );
 ${"DirectoryA/Subdirectory/MyFile.txt"}$ (3)

Compatibility

 • The FileTools[SplitPath] and FileTools[JoinPath] commands were introduced in Maple 18.