use std::fs::OpenOptions instead of File hoping that it behaves differently under windows?

This commit is contained in:
Alon Levy 2023-12-31 13:47:05 +02:00
parent 6725a9af63
commit 862a48131e

View File

@ -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<Self> {
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::<Header>();
pub struct Frame {
#[allow(dead_code)]
header: Header,
raw: Vec<u8>,
}