refactor: Remove unnecessary #[cfg] attributes

This commit is contained in:
Chris Hennick 2024-05-15 15:31:17 -07:00
parent 23068ad7c2
commit 819f86537c
No known key found for this signature in database
GPG key ID: DA47AABA4961C509
2 changed files with 20 additions and 43 deletions

View file

@ -12,32 +12,26 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
#[cfg(feature = "_deflate-any")]
{
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(())
}
#[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(())
}

View file

@ -35,23 +35,6 @@ fn 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 {
let args = Args::parse();
let src_dir = &args.source;