-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
comm: generate an error if the input is a directory #6853
base: main
Are you sure you want to change the base?
Conversation
GNU testsuite comparison:
|
tested by tests/misc/read-errors
GNU testsuite comparison:
|
let path = Path::new(name); | ||
if metadata(path)?.is_dir() { | ||
return Err(io::Error::new(io::ErrorKind::Other, "Is a directory")); | ||
} | ||
let f = File::open(path)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the path
variable necessary? Unless I'm missing something I think you can pass name
directly to metadata
and File::open
.
at.mkdir("dir"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A detail:
at.mkdir("dir"); | |
at.mkdir("dir"); |
tested by tests/misc/read-errors