Skip to content

Commit

Permalink
Feature/windows support (#21)
Browse files Browse the repository at this point in the history
* feat: windows support
  • Loading branch information
soehrl authored Nov 19, 2024
1 parent 1119fac commit fc228cd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest, windows-latest, macos-latest]

runs-on: ${{ matrix.os }}

Expand Down
18 changes: 16 additions & 2 deletions tracing-tape-recorder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,22 @@ impl Chapter {
let offset = self.offset();
let data = unsafe { self.as_bytes() };

use std::os::unix::fs::FileExt;
file.write_all_at(data, offset).unwrap();
#[cfg(unix)]
{
use std::os::unix::fs::FileExt;
file.write_all_at(data, offset).unwrap();
}
#[cfg(windows)]
{
use std::os::windows::fs::FileExt;
let mut offset = offset;
let mut data = data;
while !data.is_empty() {
let bytes_written = file.seek_write(data, offset).unwrap();
data = &data[bytes_written..];
offset += bytes_written as u64;
}
}

self.bytes_written.store(0, Ordering::Relaxed);
self.data_offset.store(u64::max_value(), Ordering::Relaxed);
Expand Down

0 comments on commit fc228cd

Please sign in to comment.