Skip to content

Commit 85a6c7f

Browse files
committed
mktemp: drop unrelated refactor from this branch
1 parent 74f38b2 commit 85a6c7f

File tree

1 file changed

+3
-25
lines changed

1 file changed

+3
-25
lines changed

src/uu/mktemp/src/mktemp.rs

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ use uucore::translate;
1414

1515
use std::env;
1616
use std::ffi::{OsStr, OsString};
17-
use std::fs;
1817
use std::io::ErrorKind;
1918
use std::iter;
2019
use std::path::{MAIN_SEPARATOR, Path, PathBuf};
2120

21+
#[cfg(unix)]
22+
use std::fs;
2223
#[cfg(unix)]
2324
use std::os::unix::prelude::PermissionsExt;
2425

@@ -396,21 +397,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
396397
} else {
397398
res
398399
};
399-
400-
let path = res?;
401-
if let Err(err) =
402-
println_verbatim(&path).map_err_context(|| translate!("mktemp-error-failed-print"))
403-
{
404-
if !dry_run {
405-
cleanup_created_path(&path, make_dir);
406-
}
407-
if suppress_file_err {
408-
return Err(1.into());
409-
}
410-
return Err(err);
411-
}
412-
413-
Ok(())
400+
println_verbatim(res?).map_err_context(|| translate!("mktemp-error-failed-print"))
414401
}
415402

416403
pub fn uu_app() -> Command {
@@ -595,15 +582,6 @@ fn exec(dir: &Path, prefix: &str, rand: usize, suffix: &str, make_dir: bool) ->
595582
Ok(path)
596583
}
597584

598-
fn cleanup_created_path(path: &Path, make_dir: bool) {
599-
let result = if make_dir {
600-
fs::remove_dir(path)
601-
} else {
602-
fs::remove_file(path)
603-
};
604-
let _ = result;
605-
}
606-
607585
/// Create a temporary file or directory
608586
///
609587
/// Behavior is determined by the `options` parameter, see [`Options`] for details.

0 commit comments

Comments
 (0)