add option for writing an archive's entries with a prefix

This commit is contained in:
Jamie Winsor
2016-01-12 00:00:30 -08:00
parent a069bd2a98
commit 39b37933d7
3 changed files with 37 additions and 16 deletions
+11 -2
View File
@@ -1,9 +1,10 @@
use std::default::Default;
use std::ffi::{CStr, CString};
use std::path::PathBuf;
use std::str;
use std::ffi::CStr;
use libarchive3_sys::ffi;
use error::ErrCode;
use error::{ArchiveResult, ErrCode};
pub enum ReadCompression {
All,
@@ -120,6 +121,14 @@ pub trait Entry {
fn size(&self) -> i64 {
unsafe { ffi::archive_entry_size(self.entry()) }
}
fn set_pathname(&mut self, path: PathBuf) -> ArchiveResult<()> {
unsafe {
let c_str = CString::new(path.to_str().unwrap()).unwrap();
ffi::archive_entry_set_pathname(self.entry(), c_str.as_ptr());
}
Ok(())
}
}
pub enum ExtractOption {