Path_Canonicalize

<< Click to Display Table of Contents >>

Navigation:  ThinBASIC Modules > File > PATH: functions working on paths >

Path_Canonicalize

 

Description

 

Simplifies a path by removing navigation elements such as "." and ".." to produce a direct, well-formed path.

 

Syntax

 

sPath = Path_Canonicalize(sPath)

 

Returns

 

String.

 

Parameters

 

Name

Type

Optional

Meaning

sPath

String

No

A disk path

 

References

 

https://learn.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-pathcanonicalizea

 

Remarks

 

Restrictions

 

sPath parameter must be a path only. Do not pass path + file name. Only path.

 

See also

 

Examples

 

uses "File"
uses "Console"
 
string sPath
 
sPath = "A:\name_1\.\name_2\..\name_3"
printl sPath,   $tab(4), "Path_Canonicalize:"Path_Canonicalize(sPath)
sPath = "A:\name_1\..\name_2\.\name_3"
printl sPath,   $tab(4), "Path_Canonicalize:"Path_Canonicalize(sPath)
sPath = "A:\name_1\name_2\.\name_3\..\name_4"
printl sPath,   $tab(3), "Path_Canonicalize:"Path_Canonicalize(sPath)
sPath = "A:\name_1\.\name_2\.\name_3\..\name_4\.."
printl sPath,   $tab(2), "Path_Canonicalize:"Path_Canonicalize(sPath)
sPath = "C:\.."
printl sPath,   $tab(7), "Path_Canonicalize:"Path_Canonicalize(sPath)
 
sPath = "\\Server\Resource\name_1\name_2\.\name_3\..\name_4"
printl sPath,   $tab(1), "Path_Canonicalize:"Path_Canonicalize(sPath)
 
WaitKey