#[repr(C)]
pub struct OpenArchiveData { pub archive_name: *const c_char, pub open_mode: c_uint, pub open_result: c_uint, pub comment_buffer: *mut c_char, pub comment_buffer_size: c_uint, pub comment_size: c_uint, pub comment_state: c_uint, }

Fields§

§archive_name: *const c_char§open_mode: c_uint§open_result: c_uint§comment_buffer: *mut c_char§comment_buffer_size: c_uint§comment_size: c_uint§comment_state: c_uint

Implementations§

source§

impl OpenArchiveData

source

pub fn new(archive: *const c_char, mode: c_uint) -> Self

Examples found in repository?
examples/lister.rs (line 30)
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
fn main() {
    let args = std::env::args();
    let mut stderr = std::io::stderr();
    let file = args.skip(1).next().unwrap_or_else(|| {
        writeln!(&mut stderr, "Please pass an archive as argument!").unwrap();
        std::process::exit(0)
    });
    extern "C" fn callback(msg: c_uint, user_data: LPARAM, p1: LPARAM, p2: LPARAM) -> c_int {
        match (msg, p2) {
            (UCM_CHANGEVOLUME, RAR_VOL_ASK) => {
                let ptr = p1 as *const _;
                let next = str::from_utf8(unsafe { CStr::from_ptr(ptr) }.to_bytes()).unwrap();
                let our_string = unsafe { &mut *(user_data as *mut String) };
                our_string.push_str(next);
                -1
            }
            (UCM_CHANGEVOLUME, RAR_VOL_NOTIFY) => 1,
            _ => 0,
        }
    }
    let file_cstr = CString::new(file).unwrap();
    let mut data = OpenArchiveData::new(file_cstr.as_ptr(), RAR_OM_LIST_INCSPLIT);
    let handle = unsafe { RAROpenArchive(&mut data as *mut _) };
    assert_eq!(data.open_result, 0);
    assert_eq!(handle.is_null(), false);
    let mut next_path = String::with_capacity(1024);
    unsafe {
        RARSetCallback(
            handle,
            Some(callback),
            &mut next_path as *mut String as LPARAM,
        )
    };
    let mut header = HeaderData::default();
    let mut result = 0;
    let mut process_result;
    let mut first = true;
    while result == 0 {
        result = unsafe { RARReadHeader(handle, &mut header as *mut _) };
        if result != ERAR_SUCCESS {
            if result != ERAR_END_ARCHIVE {
                writeln!(&mut stderr, "Error opening: {}", result).unwrap();
            }
            break;
        }
        if first && header.flags & RHDF_SPLITBEFORE != 0 {
            writeln!(&mut stderr, "Not beginning of archive! Still continuing").unwrap();
        }
        first = false;
        let s =
            str::from_utf8(unsafe { CStr::from_ptr(header.filename.as_ptr()) }.to_bytes()).unwrap();
        process_result =
            unsafe { RARProcessFile(handle, RAR_SKIP, std::ptr::null(), std::ptr::null()) };
        println!("{}", s);
        match process_result {
            ERAR_SUCCESS => (),
            ERAR_EOPEN => {
                if let Err(err) = fs::metadata(&next_path) {
                    writeln!(&mut stderr, "Couldn't find volume {}: {}", next_path, err).unwrap();
                    break;
                }
            }
            x => writeln!(&mut stderr, "Error: {}", x).unwrap(),
        }
    }
}
source

pub fn with_comment_buffer( archive_name: *const c_char, open_mode: c_uint, buffer: *mut c_char, buffer_size: c_uint ) -> Self

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.