Skip to content

Commit b3bfc27

Browse files
committed
Fixed Windows compilation.
I overlooked the fact that write_at was a unix specific API, and there is a Windows equivalent seek_write that needs to be used on Windows.
1 parent b0b6382 commit b3bfc27

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ab_versions"
3-
version = "0.10.0"
3+
version = "0.10.1"
44
authors = ["Carl J. Geib"]
55
edition = "2024"
66

src/lib.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,16 @@ use std::{
1414
fmt::Display,
1515
fs::File,
1616
io::{Read, Write},
17-
os::unix::fs::FileExt,
1817
path::Path,
1918
};
2019
use thiserror::Error;
2120

21+
#[cfg(unix)]
22+
use std::os::unix::fs::FileExt;
23+
24+
#[cfg(windows)]
25+
use std::os::windows::fs::FileExt;
26+
2227
#[derive(Error, Debug)]
2328
pub enum FTypeError {
2429
#[error("No version information was found in the file")]
@@ -425,7 +430,12 @@ pub fn fix_crc<P: AsRef<Path>>(path: P) -> Result<(), FtvFileError> {
425430
hasher.update(&buffer[..buffer.len() - 4]);
426431
let checksum = hasher.finalize();
427432

433+
#[cfg(unix)]
428434
file.write_at(&checksum.to_le_bytes(), buffer.len() as u64 - 4)?;
435+
436+
#[cfg(windows)]
437+
file.seek_write(&checksum.to_le_bytes(), buffer.len() as u64 - 4)?;
438+
429439
file.flush()?;
430440
Ok(())
431441
}
@@ -454,10 +464,10 @@ pub fn file_type<P: AsRef<Path>>(path: P) -> MeFiletype {
454464
#[cfg(test)]
455465
mod tests {
456466
use nom::{
467+
IResult,
457468
bytes::complete::{tag, take_until},
458469
character::complete::digit1,
459470
combinator::map_res,
460-
IResult,
461471
};
462472

463473
use crate::strip_protection;

0 commit comments

Comments
 (0)