Fix handling of an empty filename at end of a path