-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
split: Added error when attempting to create file that already exists as directory #9945
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
Changes from 6 commits
1984b28
32c2a1f
8c193a9
930257f
d7a9586
cb04ee6
0278b31
b011277
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,8 +4,8 @@ | |
| // file that was distributed with this source code. | ||
| use std::env; | ||
| use std::ffi::OsStr; | ||
| use std::io::Write; | ||
| use std::io::{BufWriter, Error, Result}; | ||
| use std::io::{ErrorKind, Write}; | ||
| use std::path::Path; | ||
| use std::process::{Child, Command, Stdio}; | ||
| use uucore::error::USimpleError; | ||
|
|
@@ -139,10 +139,13 @@ pub fn instantiate_current_writer( | |
| .create(true) | ||
| .truncate(true) | ||
| .open(Path::new(&filename)) | ||
| .map_err(|_| { | ||
| Error::other( | ||
| .map_err(|e| match e.kind() { | ||
| ErrorKind::IsADirectory => Error::other( | ||
| translate!("split-error-is-a-directory", "dir" => filename), | ||
| ), | ||
| _ => Error::other( | ||
| translate!("split-error-unable-to-open-file", "file" => filename), | ||
| ) | ||
| ), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it necessary?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rust linting in the pre-commit hook doesn't like it not being there, i.e. cargo fmt requires it to be there.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK thanks |
||
| })? | ||
| } else { | ||
| // re-open file that we previously created to append to it | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.