mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-27 13:04:20 +01:00
2
.github/workflows/rust.yml
vendored
2
.github/workflows/rust.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
|
||||
@@ -31,9 +31,11 @@ fallible-iterator = "0.3.0"
|
||||
log = "0.4.20"
|
||||
sqlite3-parser = "0.11.0"
|
||||
|
||||
[target.'cfg(not(target_family = "windows"))'.dev-dependencies]
|
||||
pprof = { version = "0.12.1", features = ["criterion", "flamegraph"] }
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = { version = "0.5", features = ["html_reports", "async", "async_futures"] }
|
||||
pprof = { version = "0.12.1", features = ["criterion", "flamegraph"] }
|
||||
rstest = "0.18.2"
|
||||
rusqlite = "0.29.0"
|
||||
|
||||
|
||||
@@ -102,4 +102,9 @@ cfg_block! {
|
||||
mod darwin;
|
||||
pub use darwin::DarwinIO as PlatformIO;
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")] {
|
||||
mod windows;
|
||||
pub use windows::WindowsIO as PlatformIO;
|
||||
}
|
||||
}
|
||||
|
||||
46
core/io/windows.rs
Normal file
46
core/io/windows.rs
Normal file
@@ -0,0 +1,46 @@
|
||||
use super::{Completion, File, IO};
|
||||
use anyhow::{Ok, Result};
|
||||
use std::sync::Arc;
|
||||
use std::cell::RefCell;
|
||||
use std::io::{Read, Seek};
|
||||
use log::trace;
|
||||
|
||||
pub struct WindowsIO {}
|
||||
|
||||
impl WindowsIO {
|
||||
pub fn new() -> Result<Self> {
|
||||
Ok(Self {})
|
||||
}
|
||||
}
|
||||
|
||||
impl IO for WindowsIO {
|
||||
fn open_file(&self, path: &str) -> Result<Box<dyn File>> {
|
||||
trace!("open_file(path = {})", path);
|
||||
let file = std::fs::File::open(path)?;
|
||||
Ok(Box::new(WindowsFile {
|
||||
file: RefCell::new(file),
|
||||
}))
|
||||
}
|
||||
|
||||
fn run_once(&self) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub struct WindowsFile {
|
||||
file: RefCell<std::fs::File>,
|
||||
}
|
||||
|
||||
impl File for WindowsFile {
|
||||
fn pread(&self, pos: usize, c: Arc<Completion>) -> Result<()> {
|
||||
let mut file = self.file.borrow_mut();
|
||||
file.seek(std::io::SeekFrom::Start(pos as u64))?;
|
||||
{
|
||||
let mut buf = c.buf_mut();
|
||||
let buf = buf.as_mut_slice();
|
||||
file.read_exact(buf)?;
|
||||
}
|
||||
c.complete();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user