mirror of
https://github.com/FliegendeWurst/ripgrep-all.git
synced 2024-11-24 12:24:56 +00:00
zip exclude dir
This commit is contained in:
parent
cd1a26ffff
commit
92eb76e534
@ -1,5 +1,6 @@
|
||||
use super::*;
|
||||
use crate::preproc::rga_preproc;
|
||||
use ::zip::read::ZipFile;
|
||||
use failure::*;
|
||||
use lazy_static::lazy_static;
|
||||
use std::fs::File;
|
||||
@ -32,6 +33,15 @@ impl GetMetadata for ZipAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/mvdnes/zip-rs/commit/b9af51e654793931af39f221f143b9dea524f349
|
||||
fn is_dir(f: &ZipFile) -> bool {
|
||||
f.name()
|
||||
.chars()
|
||||
.rev()
|
||||
.next()
|
||||
.map_or(false, |c| c == '/' || c == '\\')
|
||||
}
|
||||
|
||||
impl FileAdapter for ZipAdapter {
|
||||
fn adapt(&self, ai: AdaptInfo) -> Fallible<()> {
|
||||
use std::io::prelude::*;
|
||||
@ -46,6 +56,9 @@ impl FileAdapter for ZipAdapter {
|
||||
match ::zip::read::read_zipfile_from_stream(&mut inp) {
|
||||
Ok(None) => break,
|
||||
Ok(Some(mut file)) => {
|
||||
if is_dir(&file) {
|
||||
continue;
|
||||
}
|
||||
eprintln!(
|
||||
"{}|{}: {} bytes ({} bytes packed)",
|
||||
filepath_hint.to_string_lossy(),
|
||||
|
Loading…
Reference in New Issue
Block a user