The only thing I would change is reporting the actual system error, e.g. "EISDIR".