UPath is an AutoHotkey script library for developers. It gets from an Unix like file address the Windows absolute path, but it do more than that. Relative addresses, wildcards ("*" and "?") and the "." and ".." will be extended also. The returned string will contain always the full path with drive letter. On default, system files and folders don't exist to UPath. The given path can start for example with a slash "/", which is the current drive letter from script. This makes the path portable. Also a regular expression filter can be specified, to filter out founded items. Only to the regular expression matched items would be returned. Read the included manual file for more information.
The source contain several functions named with @UPath, which indicates a private function to UPath and helping to prevent some conflicts with other sources. There are 2 public functions: UPath(), the main function with all its functionality and RunUPath(), which is not really a part of UPath.
UPath is not designed to be fast as possible, but readable and changeable in mind.
May be you find it too trivial and not really useful. Yes, you may not need it, but on some situations, it could come handy to use UPath. It has some useful features and do more than a trivial string conversion. There are also some options. Here are some reasons why:
CheckAhkVersion() removed.
-q (--quot) added. Every path will be enclosed by double quotes.
<< " to " || ". This prevents some trouble in XML files.
~" is optional now.
-e or --env the working dir is also searched in environment path (at first). -E or --envonly looks only in the env path, without adding working dir.
RunUPath().
UPath is currently under heavy development phase and not tested yet well. Use it only for testing. Future releases may not be compatible anymore. Also be careful with the option --subdirs.
UPath Package, the archive contains a manual, the webpage, history file, testfiles and of course the source itself.
UPath AutoHotkey Script, is the script directly without other files.
Script := UPath("/bin/Scripts/Scriptname.ahk")
If ErrorLevel@UPath
Run, %Script%
After first line of this code the variable Script could for example contain the following string D:\bin\Scripts\Scriptname.ahk. The global variable ErrorLevel@UPath is created atomatically and contains the number of items found and returned by UPath at last. If its not zero (greater than 0), then the next Run command would be executed here.
RunUPath("/bin/Scripts/*.ahk", "notepad.exe")
RunUPath() will run directly all founded items. Any wildcard, like in this example will be extended to full path. The second argument is optional and specifies the program to start the founded file or folder with it, prior to that one which is actually registered with that filetype.
Path := UPath("//../*", "--subdirs --all --file", "UPath.*[^ks]+$")
Any path starting with two slashes will use the current scripts directory. In this example, the two dots are used, which means one up dir. This could for example be D:\home\ahkscripts\. There is an option defined file, which only let find files, no folders. The all means that all founded items would be returnd as a single semicolon separated list. The option subdirs means, that every subdirectory of given path will be searched also.
The second argument is a regular expression filter. Any path which does not match the filter, will not be found. Here, only a file if
will be found from UPath. The regex filter in UPath is always case insensitive.
All in one, the variable Path could for example contain the following string D:\Projects\UPath\UPath.history.txt;D:\Projects\UPath\upath.html;D:\Projects\UPath\UPath.man.txt.