Skip directories when creating a package from directory; Take an
optional directory when creating a package from file list;
This commit is contained in:
parent
c099790f5a
commit
ca9c0d7cdb
@ -40,6 +40,7 @@ impl Creator {
|
||||
.into_iter()
|
||||
.filter(Result::is_ok)
|
||||
.map(|x| x.unwrap().path().to_path_buf())
|
||||
.filter(|x| !x.is_dir())
|
||||
.collect::<Vec<_>>();
|
||||
env::set_current_dir(d)?;
|
||||
Ok(Self {
|
||||
@ -49,10 +50,15 @@ impl Creator {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn from_list(list: &[&str], specs: Specs) -> Result<Self, io::Error> {
|
||||
pub fn from_list(list: &[&str], path: Option<&Path>, specs: Specs) -> Result<Self, io::Error> {
|
||||
let entries = list.iter().map(|x| Path::new(x).to_path_buf()).collect();
|
||||
let path = if let Some(p) = path {
|
||||
p.to_path_buf()
|
||||
} else {
|
||||
env::current_dir().unwrap_or(Path::new("/").to_path_buf())
|
||||
};
|
||||
Ok(Self {
|
||||
path: env::current_dir().unwrap_or(Path::new("/").to_path_buf()),
|
||||
path,
|
||||
entries,
|
||||
specs,
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user