From 862a48131e52d013cadf1e814086f4202d4728a8 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Sun, 31 Dec 2023 13:47:05 +0200 Subject: [PATCH] use std::fs::OpenOptions instead of File hoping that it behaves differently under windows? --- src/lib.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 7af1dc9..4731b9a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,7 @@ use indicatif::ProgressBarIter; use png; use pyo3::exceptions::PyValueError; use pyo3::prelude::*; -use std::fs::File; +use std::fs::{File, OpenOptions}; use std::io::BufWriter; use std::path::Path; @@ -72,7 +72,11 @@ impl Iterator for PacketsIterator { impl PacketsIterator { fn new(filename: &str) -> anyhow::Result { - let file = File::open(filename)?; + let file = OpenOptions::new() + .read(true) + .write(false) + .create(false) + .open(filename)?; let pb = ProgressBar::new(file.metadata()?.len()); let wrap = pb.wrap_read(file); let cap = PcapNGReader::new(65535, wrap)?; @@ -121,6 +125,7 @@ impl Header { const HDR_SIZE: usize = std::mem::size_of::
(); pub struct Frame { + #[allow(dead_code)] header: Header, raw: Vec, }