From 70b6b326f15a592431995e4fa676b066e9b01d57 Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Thu, 13 Jul 2023 11:29:23 +0200 Subject: [PATCH] refactor: listen to clippy a lil --- libarchive/src/archive.rs | 15 ++++++ libarchive3-sys/src/ffi.rs | 96 +++++++++++++++++++------------------- 2 files changed, 63 insertions(+), 48 deletions(-) diff --git a/libarchive/src/archive.rs b/libarchive/src/archive.rs index 96e2ba4..b497894 100644 --- a/libarchive/src/archive.rs +++ b/libarchive/src/archive.rs @@ -59,6 +59,21 @@ pub enum ReadFilter { Zstd } +impl ReadFilter { + // Returns the associated file extension for the filter, if known + pub fn extension(&self) -> Option<&str> { + match self { + ReadFilter::None => Some(""), + ReadFilter::Gzip => Some(".gz"), + ReadFilter::Bzip2 => Some(".bz2"), + ReadFilter::Lzma => Some(".lzma"), + ReadFilter::Xz => Some(".xz"), + ReadFilter::Zstd => Some(".zstd"), + _ => None + } + } +} + #[derive(Debug, PartialEq, Eq)] pub enum WriteFormat { SevenZip, diff --git a/libarchive3-sys/src/ffi.rs b/libarchive3-sys/src/ffi.rs index 5490ae8..e2f347f 100644 --- a/libarchive3-sys/src/ffi.rs +++ b/libarchive3-sys/src/ffi.rs @@ -49,13 +49,13 @@ pub type archive_read_callback = unsafe extern "C" fn(arg1: *mut Struct_archive, -> ssize_t; pub type archive_skip_callback = unsafe extern "C" fn(arg1: *mut Struct_archive, _client_data: *mut c_void, - request: int64_t) - -> int64_t; + request: i64) + -> i64; pub type archive_seek_callback = unsafe extern "C" fn(arg1: *mut Struct_archive, _client_data: *mut c_void, - offset: int64_t, + offset: i64, whence: c_int) - -> int64_t; + -> i64; pub type archive_write_callback = unsafe extern "C" fn(arg1: *mut Struct_archive, _client_data: *mut c_void, _buffer: *const c_void, @@ -159,13 +159,13 @@ extern "C" { arg2: *mut ::std::option::Option - int64_t>) + i64>) -> c_int; pub fn archive_read_set_skip_callback(arg1: *mut Struct_archive, arg2: *mut ::std::option::Option - int64_t>) + i64>) -> c_int; pub fn archive_read_set_close_callback(arg1: *mut Struct_archive, arg2: @@ -205,7 +205,7 @@ extern "C" { _client_data: *mut c_void, arg2: *mut ::std::option::Option c_int>, arg3: *mut ::std::option::Option ssize_t>, - arg4: *mut ::std::option::Option int64_t>, + arg4: *mut ::std::option::Option i64>, arg5: *mut ::std::option::Option c_int>) -> c_int; pub fn archive_read_open_filename(arg1: *mut Struct_archive, @@ -244,16 +244,16 @@ extern "C" { pub fn archive_read_next_header2(arg1: *mut Struct_archive, arg2: *mut Struct_archive_entry) -> c_int; - pub fn archive_read_header_position(arg1: *mut Struct_archive) -> int64_t; + pub fn archive_read_header_position(arg1: *mut Struct_archive) -> i64; pub fn archive_read_data(arg1: *mut Struct_archive, arg2: *mut c_void, arg3: size_t) -> ssize_t; - pub fn archive_seek_data(arg1: *mut Struct_archive, arg2: int64_t, arg3: c_int) -> int64_t; + pub fn archive_seek_data(arg1: *mut Struct_archive, arg2: i64, arg3: c_int) -> i64; pub fn archive_read_data_block(a: *mut Struct_archive, buff: *mut *const c_void, size: *mut size_t, - offset: *mut int64_t) + offset: *mut i64) -> c_int; pub fn archive_read_data_skip(arg1: *mut Struct_archive) -> c_int; pub fn archive_read_data_into_fd(arg1: *mut Struct_archive, fd: c_int) -> c_int; @@ -292,8 +292,8 @@ extern "C" { *mut c_void) -> (); pub fn archive_read_extract_set_skip_file(arg1: *mut Struct_archive, - arg2: int64_t, - arg3: int64_t) + arg2: i64, + arg3: i64) -> (); pub fn archive_read_close(arg1: *mut Struct_archive) -> c_int; pub fn archive_read_free(arg1: *mut Struct_archive) -> c_int; @@ -308,8 +308,8 @@ extern "C" { -> c_int; pub fn archive_write_get_bytes_in_last_block(arg1: *mut Struct_archive) -> c_int; pub fn archive_write_set_skip_file(arg1: *mut Struct_archive, - arg2: int64_t, - arg3: int64_t) + arg2: i64, + arg3: i64) -> c_int; pub fn archive_write_set_compression_bzip2(arg1: *mut Struct_archive) -> c_int; pub fn archive_write_set_compression_compress(arg1: *mut Struct_archive) -> c_int; @@ -391,7 +391,7 @@ extern "C" { pub fn archive_write_data_block(arg1: *mut Struct_archive, arg2: *const c_void, arg3: size_t, - arg4: int64_t) + arg4: i64) -> ssize_t; pub fn archive_write_finish_entry(arg1: *mut Struct_archive) -> c_int; pub fn archive_write_close(arg1: *mut Struct_archive) -> c_int; @@ -416,8 +416,8 @@ extern "C" { pub fn archive_write_set_options(_a: *mut Struct_archive, opts: *const c_char) -> c_int; pub fn archive_write_disk_new() -> *mut Struct_archive; pub fn archive_write_disk_set_skip_file(arg1: *mut Struct_archive, - arg2: int64_t, - arg3: int64_t) + arg2: i64, + arg3: i64) -> c_int; pub fn archive_write_disk_set_options(arg1: *mut Struct_archive, flags: c_int) -> c_int; pub fn archive_write_disk_set_standard_lookup(arg1: *mut Struct_archive) -> c_int; @@ -429,9 +429,9 @@ extern "C" { arg2: *const c_char, arg3: - int64_t) + i64) -> - int64_t>, + i64>, arg4: ::std::option::Option - int64_t>, + i64>, arg4: ::std::option::Option c_int; pub fn archive_write_disk_gid(arg1: *mut Struct_archive, arg2: *const c_char, - arg3: int64_t) - -> int64_t; + arg3: i64) + -> i64; pub fn archive_write_disk_uid(arg1: *mut Struct_archive, arg2: *const c_char, - arg3: int64_t) - -> int64_t; + arg3: i64) + -> i64; pub fn archive_read_disk_new() -> *mut Struct_archive; pub fn archive_read_disk_set_symlink_logical(arg1: *mut Struct_archive) -> c_int; pub fn archive_read_disk_set_symlink_physical(arg1: *mut Struct_archive) -> c_int; @@ -472,8 +472,8 @@ extern "C" { // arg3: c_int, // arg4: *const Struct_stat) // -> c_int; - pub fn archive_read_disk_gname(arg1: *mut Struct_archive, arg2: int64_t) -> *const c_char; - pub fn archive_read_disk_uname(arg1: *mut Struct_archive, arg2: int64_t) -> *const c_char; + pub fn archive_read_disk_gname(arg1: *mut Struct_archive, arg2: i64) -> *const c_char; + pub fn archive_read_disk_uname(arg1: *mut Struct_archive, arg2: i64) -> *const c_char; pub fn archive_read_disk_set_standard_lookup(arg1: *mut Struct_archive) -> c_int; pub fn archive_read_disk_set_gname_lookup(arg1: *mut Struct_archive, arg2: *mut c_void, @@ -481,7 +481,7 @@ extern "C" { ::std::option::Option *const c_char>, arg4: @@ -496,7 +496,7 @@ extern "C" { ::std::option::Option *const c_char>, arg4: @@ -542,11 +542,11 @@ extern "C" { *mut c_void) -> c_int; pub fn archive_filter_count(arg1: *mut Struct_archive) -> c_int; - pub fn archive_filter_bytes(arg1: *mut Struct_archive, arg2: c_int) -> int64_t; + pub fn archive_filter_bytes(arg1: *mut Struct_archive, arg2: c_int) -> i64; pub fn archive_filter_code(arg1: *mut Struct_archive, arg2: c_int) -> c_int; pub fn archive_filter_name(arg1: *mut Struct_archive, arg2: c_int) -> *const c_char; - pub fn archive_position_compressed(arg1: *mut Struct_archive) -> int64_t; - pub fn archive_position_uncompressed(arg1: *mut Struct_archive) -> int64_t; + pub fn archive_position_compressed(arg1: *mut Struct_archive) -> i64; + pub fn archive_position_uncompressed(arg1: *mut Struct_archive) -> i64; pub fn archive_compression_name(arg1: *mut Struct_archive) -> *const c_char; pub fn archive_compression(arg1: *mut Struct_archive) -> c_int; pub fn archive_errno(arg1: *mut Struct_archive) -> c_int; @@ -631,8 +631,8 @@ extern "C" { pub fn archive_match_owner_excluded(arg1: *mut Struct_archive, arg2: *mut Struct_archive_entry) -> c_int; - pub fn archive_match_include_uid(arg1: *mut Struct_archive, arg2: int64_t) -> c_int; - pub fn archive_match_include_gid(arg1: *mut Struct_archive, arg2: int64_t) -> c_int; + pub fn archive_match_include_uid(arg1: *mut Struct_archive, arg2: i64) -> c_int; + pub fn archive_match_include_gid(arg1: *mut Struct_archive, arg2: i64) -> c_int; pub fn archive_match_include_uname(arg1: *mut Struct_archive, arg2: *const c_char) -> c_int; pub fn archive_match_include_uname_w(arg1: *mut Struct_archive, arg2: *const wchar_t) -> c_int; pub fn archive_match_include_gname(arg1: *mut Struct_archive, arg2: *const c_char) -> c_int; @@ -661,13 +661,13 @@ extern "C" { arg3: *mut c_ulong) -> (); pub fn archive_entry_fflags_text(arg1: *mut Struct_archive_entry) -> *const c_char; - pub fn archive_entry_gid(arg1: *mut Struct_archive_entry) -> int64_t; + pub fn archive_entry_gid(arg1: *mut Struct_archive_entry) -> i64; pub fn archive_entry_gname(arg1: *mut Struct_archive_entry) -> *const c_char; pub fn archive_entry_gname_w(arg1: *mut Struct_archive_entry) -> *const wchar_t; pub fn archive_entry_hardlink(arg1: *mut Struct_archive_entry) -> *const c_char; pub fn archive_entry_hardlink_w(arg1: *mut Struct_archive_entry) -> *const wchar_t; - pub fn archive_entry_ino(arg1: *mut Struct_archive_entry) -> int64_t; - pub fn archive_entry_ino64(arg1: *mut Struct_archive_entry) -> int64_t; + pub fn archive_entry_ino(arg1: *mut Struct_archive_entry) -> i64; + pub fn archive_entry_ino64(arg1: *mut Struct_archive_entry) -> i64; pub fn archive_entry_ino_is_set(arg1: *mut Struct_archive_entry) -> c_int; pub fn archive_entry_mode(arg1: *mut Struct_archive_entry) -> mode_t; pub fn archive_entry_mtime(arg1: *mut Struct_archive_entry) -> time_t; @@ -682,12 +682,12 @@ extern "C" { pub fn archive_entry_rdevminor(arg1: *mut Struct_archive_entry) -> dev_t; pub fn archive_entry_sourcepath(arg1: *mut Struct_archive_entry) -> *const c_char; pub fn archive_entry_sourcepath_w(arg1: *mut Struct_archive_entry) -> *const wchar_t; - pub fn archive_entry_size(arg1: *mut Struct_archive_entry) -> int64_t; + pub fn archive_entry_size(arg1: *mut Struct_archive_entry) -> i64; pub fn archive_entry_size_is_set(arg1: *mut Struct_archive_entry) -> c_int; pub fn archive_entry_strmode(arg1: *mut Struct_archive_entry) -> *const c_char; pub fn archive_entry_symlink(arg1: *mut Struct_archive_entry) -> *const c_char; pub fn archive_entry_symlink_w(arg1: *mut Struct_archive_entry) -> *const wchar_t; - pub fn archive_entry_uid(arg1: *mut Struct_archive_entry) -> int64_t; + pub fn archive_entry_uid(arg1: *mut Struct_archive_entry) -> i64; pub fn archive_entry_uname(arg1: *mut Struct_archive_entry) -> *const c_char; pub fn archive_entry_uname_w(arg1: *mut Struct_archive_entry) -> *const wchar_t; pub fn archive_entry_set_atime(arg1: *mut Struct_archive_entry, @@ -719,7 +719,7 @@ extern "C" { pub fn archive_entry_copy_fflags_text_w(arg1: *mut Struct_archive_entry, arg2: *const wchar_t) -> *const wchar_t; - pub fn archive_entry_set_gid(arg1: *mut Struct_archive_entry, arg2: int64_t) -> (); + pub fn archive_entry_set_gid(arg1: *mut Struct_archive_entry, arg2: i64) -> (); pub fn archive_entry_set_gname(arg1: *mut Struct_archive_entry, arg2: *const c_char) -> (); pub fn archive_entry_copy_gname(arg1: *mut Struct_archive_entry, arg2: *const c_char) -> (); pub fn archive_entry_copy_gname_w(arg1: *mut Struct_archive_entry, arg2: *const wchar_t) -> (); @@ -734,8 +734,8 @@ extern "C" { pub fn archive_entry_update_hardlink_utf8(arg1: *mut Struct_archive_entry, arg2: *const c_char) -> c_int; - pub fn archive_entry_set_ino(arg1: *mut Struct_archive_entry, arg2: int64_t) -> (); - pub fn archive_entry_set_ino64(arg1: *mut Struct_archive_entry, arg2: int64_t) -> (); + pub fn archive_entry_set_ino(arg1: *mut Struct_archive_entry, arg2: i64) -> (); + pub fn archive_entry_set_ino64(arg1: *mut Struct_archive_entry, arg2: i64) -> (); pub fn archive_entry_set_link(arg1: *mut Struct_archive_entry, arg2: *const c_char) -> (); pub fn archive_entry_copy_link(arg1: *mut Struct_archive_entry, arg2: *const c_char) -> (); pub fn archive_entry_copy_link_w(arg1: *mut Struct_archive_entry, arg2: *const wchar_t) -> (); @@ -761,7 +761,7 @@ extern "C" { pub fn archive_entry_set_rdev(arg1: *mut Struct_archive_entry, arg2: dev_t) -> (); pub fn archive_entry_set_rdevmajor(arg1: *mut Struct_archive_entry, arg2: dev_t) -> (); pub fn archive_entry_set_rdevminor(arg1: *mut Struct_archive_entry, arg2: dev_t) -> (); - pub fn archive_entry_set_size(arg1: *mut Struct_archive_entry, arg2: int64_t) -> (); + pub fn archive_entry_set_size(arg1: *mut Struct_archive_entry, arg2: i64) -> (); pub fn archive_entry_unset_size(arg1: *mut Struct_archive_entry) -> (); pub fn archive_entry_copy_sourcepath(arg1: *mut Struct_archive_entry, arg2: *const c_char) @@ -777,7 +777,7 @@ extern "C" { pub fn archive_entry_update_symlink_utf8(arg1: *mut Struct_archive_entry, arg2: *const c_char) -> c_int; - pub fn archive_entry_set_uid(arg1: *mut Struct_archive_entry, arg2: int64_t) -> (); + pub fn archive_entry_set_uid(arg1: *mut Struct_archive_entry, arg2: i64) -> (); pub fn archive_entry_set_uname(arg1: *mut Struct_archive_entry, arg2: *const c_char) -> (); pub fn archive_entry_copy_uname(arg1: *mut Struct_archive_entry, arg2: *const c_char) -> (); pub fn archive_entry_copy_uname_w(arg1: *mut Struct_archive_entry, arg2: *const wchar_t) -> (); @@ -848,14 +848,14 @@ extern "C" { -> c_int; pub fn archive_entry_sparse_clear(arg1: *mut Struct_archive_entry) -> (); pub fn archive_entry_sparse_add_entry(arg1: *mut Struct_archive_entry, - arg2: int64_t, - arg3: int64_t) + arg2: i64, + arg3: i64) -> (); pub fn archive_entry_sparse_count(arg1: *mut Struct_archive_entry) -> c_int; pub fn archive_entry_sparse_reset(arg1: *mut Struct_archive_entry) -> c_int; pub fn archive_entry_sparse_next(arg1: *mut Struct_archive_entry, - arg2: *mut int64_t, - arg3: *mut int64_t) + arg2: *mut i64, + arg3: *mut i64) -> c_int; pub fn archive_entry_linkresolver_new() -> *mut Struct_archive_entry_linkresolver; pub fn archive_entry_linkresolver_set_strategy(arg1: *mut Struct_archive_entry_linkresolver,