refactor: Remove unnecessary #[cfg] attributes
This commit is contained in:
parent
23068ad7c2
commit
819f86537c
2 changed files with 20 additions and 43 deletions
|
@ -12,32 +12,26 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
#[cfg(feature = "_deflate-any")]
|
#[cfg(feature = "_deflate-any")]
|
||||||
{
|
{
|
||||||
let filename = &*args[1];
|
let filename = &*args[1];
|
||||||
doit(filename)?;
|
use std::io::Write;
|
||||||
|
|
||||||
|
use zip::write::SimpleFileOptions;
|
||||||
|
|
||||||
|
let file = std::fs::File::create(filename)?;
|
||||||
|
let mut zip = zip::ZipWriter::new(file);
|
||||||
|
|
||||||
|
let options = SimpleFileOptions::default()
|
||||||
|
.compression_method(zip::CompressionMethod::Deflated)
|
||||||
|
// files over u32::MAX require this flag set.
|
||||||
|
.large_file(true)
|
||||||
|
.unix_permissions(0o755);
|
||||||
|
zip.start_file("huge-file-of-zeroes", options)?;
|
||||||
|
let content: Vec<_> = std::iter::repeat(0_u8).take(65 * 1024).collect();
|
||||||
|
let mut bytes_written = 0_u64;
|
||||||
|
while bytes_written < u32::MAX as u64 {
|
||||||
|
zip.write_all(&content)?;
|
||||||
|
bytes_written += content.len() as u64;
|
||||||
|
}
|
||||||
|
zip.finish()?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "_deflate-any")]
|
|
||||||
fn doit(filename: &str) -> zip::result::ZipResult<()> {
|
|
||||||
use std::io::Write;
|
|
||||||
|
|
||||||
use zip::write::SimpleFileOptions;
|
|
||||||
|
|
||||||
let file = std::fs::File::create(filename)?;
|
|
||||||
let mut zip = zip::ZipWriter::new(file);
|
|
||||||
|
|
||||||
let options = SimpleFileOptions::default()
|
|
||||||
.compression_method(zip::CompressionMethod::Deflated)
|
|
||||||
// files over u32::MAX require this flag set.
|
|
||||||
.large_file(true)
|
|
||||||
.unix_permissions(0o755);
|
|
||||||
zip.start_file("huge-file-of-zeroes", options)?;
|
|
||||||
let content: Vec<_> = std::iter::repeat(0_u8).take(65 * 1024).collect();
|
|
||||||
let mut bytes_written = 0_u64;
|
|
||||||
while bytes_written < u32::MAX as u64 {
|
|
||||||
zip.write_all(&content)?;
|
|
||||||
bytes_written += content.len() as u64;
|
|
||||||
}
|
|
||||||
zip.finish()?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
|
@ -35,23 +35,6 @@ fn main() {
|
||||||
std::process::exit(real_main());
|
std::process::exit(real_main());
|
||||||
}
|
}
|
||||||
|
|
||||||
const METHOD_STORED: Option<zip::CompressionMethod> = Some(zip::CompressionMethod::Stored);
|
|
||||||
|
|
||||||
#[cfg(feature = "_deflate-any")]
|
|
||||||
const METHOD_DEFLATED: Option<zip::CompressionMethod> = Some(zip::CompressionMethod::Deflated);
|
|
||||||
#[cfg(not(feature = "_deflate-any"))]
|
|
||||||
const METHOD_DEFLATED: Option<zip::CompressionMethod> = None;
|
|
||||||
|
|
||||||
#[cfg(feature = "bzip2")]
|
|
||||||
const METHOD_BZIP2: Option<zip::CompressionMethod> = Some(zip::CompressionMethod::Bzip2);
|
|
||||||
#[cfg(not(feature = "bzip2"))]
|
|
||||||
const METHOD_BZIP2: Option<zip::CompressionMethod> = None;
|
|
||||||
|
|
||||||
#[cfg(feature = "zstd")]
|
|
||||||
const METHOD_ZSTD: Option<zip::CompressionMethod> = Some(zip::CompressionMethod::Zstd);
|
|
||||||
#[cfg(not(feature = "zstd"))]
|
|
||||||
const METHOD_ZSTD: Option<zip::CompressionMethod> = None;
|
|
||||||
|
|
||||||
fn real_main() -> i32 {
|
fn real_main() -> i32 {
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
let src_dir = &args.source;
|
let src_dir = &args.source;
|
||||||
|
|
Loading…
Add table
Reference in a new issue