Skip to content

Commit 1ea8974

Browse files
committed
fix: Add Windows support for file I/O operations
- Add conditional import of std::os::windows::fs::FileExt on Windows - Use FileExt::seek_read on Windows instead of Unix-specific read_exact_at - Keep fallback implementation for other platforms - Fixes compilation error on Windows where std::os::unix was not available 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> Signed-off-by: Claude <[email protected]>
1 parent 138f721 commit 1ea8974

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

vortex-io/src/file/std_file.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
// SPDX-FileCopyrightText: Copyright the Vortex contributors
33

44
use std::fs::File;
5+
#[cfg(unix)]
56
use std::os::unix::fs::FileExt;
7+
#[cfg(windows)]
8+
use std::os::windows::fs::FileExt;
69
use std::path::{Path, PathBuf};
710
use std::sync::Arc;
811

@@ -85,10 +88,16 @@ impl ReadSource for FileIoSource {
8588

8689
#[cfg(unix)]
8790
let buffer_res = file.read_exact_at(&mut buffer, offset);
88-
#[cfg(not(unix))]
89-
let buffer_res = file
90-
.seek(io::SeekFrom::Start(offset))
91-
.and_then(|_| file.read_exact(&mut buffer));
91+
#[cfg(windows)]
92+
let buffer_res = file.seek_read(&mut buffer, offset);
93+
#[cfg(not(any(unix, windows)))]
94+
let buffer_res = {
95+
use std::io::{Read, Seek, SeekFrom};
96+
let mut file_ref = file.as_ref();
97+
file_ref
98+
.seek(SeekFrom::Start(offset))
99+
.and_then(|_| file_ref.read_exact(&mut buffer))
100+
};
92101

93102
req.resolve(
94103
buffer_res

0 commit comments

Comments
 (0)