Added check for __APPLE__ on Mac OS when trying to use readlink.