mirror of
https://codeberg.org/icewind/logsmash.git
synced 2026-06-03 18:14:11 +02:00
support reading log.gz files
This commit is contained in:
parent
6213aff07e
commit
4737a0db3c
4 changed files with 13 additions and 3 deletions
|
|
@ -1,4 +1,5 @@
|
|||
use crate::error::ReadError;
|
||||
use flate2::read::GzDecoder;
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
use zip::ZipArchive;
|
||||
|
|
@ -22,6 +23,12 @@ impl LogFile {
|
|||
let mut content = String::with_capacity(log.size() as usize);
|
||||
log.read_to_string(&mut content)?;
|
||||
|
||||
Ok(LogFile { content })
|
||||
} else if path.ends_with(".gz") {
|
||||
let mut decoder = GzDecoder::new(file);
|
||||
let mut content = String::new();
|
||||
decoder.read_to_string(&mut content)?;
|
||||
|
||||
Ok(LogFile { content })
|
||||
} else {
|
||||
let mut content = String::new();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue