mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-06 11:35:45 +00:00
Allow empty dirs on tar
This commit is contained in:
parent
0c65fbd2d4
commit
e352f8bc93
@ -51,7 +51,9 @@ where
|
||||
let path = entry.path();
|
||||
|
||||
println!("Compressing '{}'.", utils::to_utf(path));
|
||||
if !path.is_dir() {
|
||||
if path.is_dir() {
|
||||
builder.append_dir(path, path)?;
|
||||
} else {
|
||||
let mut file = fs::File::open(path)?;
|
||||
builder.append_file(path, &mut file)?;
|
||||
}
|
||||
|
@ -5,7 +5,12 @@ use std::{env, path::PathBuf};
|
||||
use utils::*;
|
||||
|
||||
#[test]
|
||||
fn test_compress_decompress_with_empty_dir() {
|
||||
fn test_each_format() {
|
||||
test_compress_decompress_with_empty_dir("tar");
|
||||
test_compress_decompress_with_empty_dir("zip");
|
||||
}
|
||||
|
||||
fn test_compress_decompress_with_empty_dir(format: &str) {
|
||||
// System temporary directory depends on the platform, for linux it's /tmp
|
||||
let system_tmp = env::temp_dir();
|
||||
|
||||
@ -19,8 +24,6 @@ fn test_compress_decompress_with_empty_dir() {
|
||||
|
||||
let mut file_paths: Vec<PathBuf> = vec![empty_dir_path];
|
||||
|
||||
let format = "zip";
|
||||
|
||||
let compressed_archive_path: PathBuf = compress_files(&testing_dir_path, &file_paths, &format);
|
||||
|
||||
let mut extracted_paths = extract_files(&compressed_archive_path);
|
||||
|
Loading…
x
Reference in New Issue
Block a user