There is a standard API for this.
Code: Select all
GetFullPathName(path) {
cc := DllCall("GetFullPathName", "str", path, "uint", 0, "ptr", 0, "ptr", 0, "uint")
VarSetCapacity(buf, cc*(A_IsUnicode?2:1))
DllCall("GetFullPathName", "str", path, "uint", cc, "str", buf, "ptr", 0, "uint")
return buf
}
Or using BufferAlloc (v2 only):
Code: Select all
GetFullPathName(path) {
cc := DllCall("GetFullPathNameW", "str", path, "uint", 0, "ptr", 0, "ptr", 0, "uint")
buf := BufferAlloc(cc*2)
DllCall("GetFullPathNameW", "str", path, "uint", cc, "ptr", buf, "ptr", 0, "uint")
return StrGet(buf)
}
I often use
\folder-in-root-directory.
There's also
c:foo, being "foo" in the current working directory for C:. If the actual working directory is on C:, it just uses that, otherwise it uses the value of a
strange environment variable,
=C:, which is normally only set if the process was launched by cmd.exe. If they aren't set, it ends up being the root directory for that drive. I don't expect it's used much in scripts, but it pays to at least be aware that
c:foo is not equivalent to
c:\foo, except by chance.
There may be other quirks I'm forgetting.