From 8b1ca494393f56f6af7d79bf737eb510c63f465e Mon Sep 17 00:00:00 2001 From: Igor Katson Date: Mon, 19 Aug 2024 13:58:05 +0100 Subject: [PATCH] fix windows build --- crates/librqbit/src/storage/filesystem/fs.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/crates/librqbit/src/storage/filesystem/fs.rs b/crates/librqbit/src/storage/filesystem/fs.rs index 5d202b0..9e5b45e 100644 --- a/crates/librqbit/src/storage/filesystem/fs.rs +++ b/crates/librqbit/src/storage/filesystem/fs.rs @@ -61,12 +61,22 @@ impl TorrentStorage for FilesystemStorage { .context("file is None")? .read_exact_at(buf, offset)?) } - #[cfg(not(target_family = "unix"))] + #[cfg(target_family = "windows")] + { + use std::os::windows::fs::FileExt; + let mut remaining = buf.len(); + let g = of.file.read(); + let f = g.as_ref().context("file is None")?; + f.seek_read(buf, offset)?; + Ok(()) + } + #[cfg(not(any(target_family = "unix", target_family = "windows")))] { use std::io::{Read, Seek, SeekFrom}; let mut g = of.file.write(); - g.seek(SeekFrom::Start(offset))?; - Ok(g.read_exact(buf)?) + let mut f = g.as_ref().context("file is None")?; + f.seek(SeekFrom::Start(offset))?; + Ok(f.read_exact(buf)?) } }