baseline
This commit is contained in:
@@ -2,14 +2,18 @@
|
||||
//
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::{
|
||||
fs::File,
|
||||
path::PathBuf,
|
||||
path::{Path, PathBuf},
|
||||
sync::{Arc, LazyLock, Mutex},
|
||||
};
|
||||
|
||||
use tempfile::TempDir;
|
||||
use uucore::error::UResult;
|
||||
use uucore::{
|
||||
error::{UResult, USimpleError},
|
||||
show_error, translate,
|
||||
};
|
||||
|
||||
use crate::{SortError, current_open_fd_count, fd_soft_limit};
|
||||
|
||||
@@ -175,3 +179,15 @@ impl Drop for TmpDirWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
/// Remove the directory at `path` by deleting its child files and then itself.
|
||||
/// Errors while deleting child files are ignored.
|
||||
fn remove_tmp_dir(path: &Path) -> std::io::Result<()> {
|
||||
if let Ok(read_dir) = std::fs::read_dir(path) {
|
||||
for file in read_dir.flatten() {
|
||||
// if we fail to delete the file here it was probably deleted by another thread
|
||||
// in the meantime, but that's ok.
|
||||
let _ = std::fs::remove_file(file.path());
|
||||
}
|
||||
}
|
||||
std::fs::remove_dir(path)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user