Requires: GfaWinx.lg32
Breaks a path name (UNC included) into its components drive, directory, filename, and extension.
SplitPath FName$, Drive$, Dir$, FileName$, Ext$
FName$ | : string expression |
Drive$, Dir$, FileName$, Ext$ | : string variables |
SplitPath parses the filepath from the string expression FName and stores it's components drive, directory, filename, and extension in the specified string variables. SplitPath handles both normal path and UNC path expressions.
After parsing Drive$ contains the drive-letter plus : ("X:"), Dir$ contains the path starting and ending with a backslash ("\path\sub\"), FileName$ contains the filename without extension, and Ext$ holds the extension starting with the dot (".ext").
When FName is an UNC path specification Drive$ which contains the first part starting with \\ until (but without) the next backslash ("\\MyServer"), the other values are the same.
$Library "gfawinx"
Debug.Show
Local String sDrive, sDir, sFileName, sExt
SplitPath "C:\WINDOWS\SYSTEM.INI", sDrive, sDir, sFileName, sExt
Trace sDrive ' "C:"
Trace sDir ' "\WINDOWS\"
Trace sFileName ' "SYSTEM"
Trace sExt ' ".INI"
SplitPath "\\MyServer\Drive-C\MyDir\file.ext", sDrive, sDir, sFileName, sExt
Trace sDrive ' "\\MyServer"
Trace sDir ' "\Drive-C\MyDir\"
Trace sFileName ' "file"
Trace sExt ' ".ext"
SplitPath is compatible with the C library function _splitpath().
{Created by Sjouke Hamstra; Last updated: 24/08/2021 by James Gaite}