Skip to content

Commit

Permalink
fix windows builds
Browse files Browse the repository at this point in the history
  • Loading branch information
pjtatlow committed Apr 7, 2020
1 parent 5ba3b44 commit f49e9f8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
11 changes: 3 additions & 8 deletions src/node.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
use std::fs::File;
use std::io::{Seek, SeekFrom, Write};
use std::mem::size_of;

#[cfg(unix)]
use std::os::unix::fs::FileExt;

#[cfg(windows)]
use std::os::windows::fs::FileExt;

use crate::bucket::Bucket;
use crate::cursor::PageNodeID;
use crate::data::{Data, SliceParts};
Expand Down Expand Up @@ -241,8 +236,8 @@ impl Node {
let page = unsafe { &mut *(&mut buf[0] as *mut u8 as *mut Page) };
page.write_node(self, self.num_pages)?;
let offset = (self.page_id as u64) * (self.bucket.tx.meta.pagesize as u64);
// println!("WRITING PAGE: {:?} at {}", page, offset);
file.write_all_at(buf.as_slice(), offset)?;
file.seek(SeekFrom::Start(offset))?;
file.write_all(buf.as_slice())?;
Ok(())
}

Expand Down
15 changes: 6 additions & 9 deletions src/transaction.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
use std::fs::File;
use std::io::Write;
use std::io::{Seek, SeekFrom, Write};
use std::pin::Pin;
use std::sync::{Arc, MutexGuard};

#[cfg(unix)]
use std::os::unix::fs::FileExt;

#[cfg(windows)]
use std::os::windows::fs::FileExt;

use memmap::Mmap;

use crate::bucket::Bucket;
Expand Down Expand Up @@ -299,7 +293,8 @@ impl<'a> TransactionInner {
page.count = page_ids.len() as u64;
page.freelist_mut().copy_from_slice(page_ids.as_slice());

file.write_all_at(buf.as_slice(), (self.db.pagesize * page_id) as u64)?;
file.seek(SeekFrom::Start((self.db.pagesize * page_id) as u64))?;
file.write_all(buf.as_slice())?;

self.meta.freelist_page = page_id;
}
Expand All @@ -323,7 +318,9 @@ impl<'a> TransactionInner {
m.freelist_page = self.meta.freelist_page;
m.tx_id = self.meta.tx_id;
m.hash = m.hash_self();
file.write_all_at(buf.as_slice(), (self.db.pagesize * meta_page_id) as u64)?;

file.seek(SeekFrom::Start((self.db.pagesize * meta_page_id) as u64))?;
file.write_all(buf.as_slice())?;
}

file.flush()?;
Expand Down

0 comments on commit f49e9f8

Please sign in to comment.