[Fix #46] Use a more reliable method to determine a remote file's localname