FileTools - Maple Programming Help

Online Help

All Products    Maple    MapleSim


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

FileTools

  

SplitPath

  

split filepath into components

  

JoinPath

  

join components into filepath

 

Calling Sequence

Parameters

Options

Description

Examples

Compatibility

Calling Sequence

SplitPath(filepath, opts)

JoinPath(components, opts)

Parameters

filepath

-

string; filepath, relative or absolute

components

-

list of strings; components of a filepath, relative or absolute

opts

-

options as described below

Options

• 

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 worksheetdir see interface; for any other of these symbols, see kernelopts. This option is only supported for JoinPath.

• 

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.

Description

• 

The SplitPath command splits a filepath into a list of its path components. The JoinPath(components) command joins a list of path components into a filepath 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" );

C:,Program Files,Microsoft Office

(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.

• 

For more information on Maple 18 changes, see Updates in Maple 18.

See Also

FileTools

FileTools[Filename]

FileTools[ParentDirectory]