@REALPATH variable function.

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
Aug 23, 2010
The more I use TCC, the more I need for a way to obtain full, unambiguous path to various system files.
@FULL is useless, as it
…makes no assumption about the existence of a file or directory. The filename parameter can be any string and the function will attempt to turn it into a fully qualified "volume + path + name" specification, whether that full reference exists or not.
Another problem of the @FULL function (same as with @PATH) is that it always preserve trailing slash in paths, leading to cumbersome code when you need to travel directory structure upwards.

My suggestion is to add @REALPATH[ [skip,] filename ] function with the following behavior:
The function walks the directory structure upwards, dereferencing any symlinks and reparse points, except links leading to volume mount points ("\\?\Volume{…}") to recreate the original path to the filename.
The skip parameter, defaults to "0", indicates, how many parts of the original argument are allowed to not exist on the filesystem. If argument contains fewer parts than specified by skip, the warning is issued.
If the function fails to construct path, an empty string is returned.