Changed logic for detecting file or directory, removes localdir param