directory detection should now work on BSDs, added AIX alternate path

This should fix #5970, #5741 and #5659

Small changes but I don't have AIX nor all the BSDs available for testing so I ask those that do to test this patch.