amicommon: a better and less hacky way to retrive the path. additionally this variant also works properly on AROS

git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@28513 3ad0048d-3df7-0310-abae-a5850022a9f2