$longfn() will always give you an absolute path and works with both files and directories. You'd just need to combine it with $isfile, $isdir, or $exists.
The only thing it doesn't handle is to eliminate ".." (parent directory) references, i.e.:
//echo -a $longfn(C:\Program Files (x86)\mIRC\..\mIRC\)
will give you
C:\Program Files (x86)\mIRC\..\mIRC\
and not
C:\Program Files (x86)\mIRC\
but this might not be important for your purposes.