Skip to content

Commit

Permalink
Fix a windows incompatibility in connection.rs libsql-sys.
Browse files Browse the repository at this point in the history
  • Loading branch information
milen-denev committed Nov 8, 2024
1 parent fa06fc2 commit ad4188d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion libsql-sys/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,23 @@ impl<W: Wal> Connection<W> {
conn
};

#[cfg(not(target_os = "windows"))]
use std::os::unix::ffi::OsStrExt;

#[cfg(target_os = "windows")]
use std::os::windows::ffi::OsStrExt;

#[cfg(not(feature = "rusqlite"))]
let conn = unsafe {
use std::os::unix::ffi::OsStrExt;

#[cfg(target_os = "windows")]
let path = std::ffi::CString::new(path.as_ref().as_os_str().as_encoded_bytes())
.map_err(|_| crate::error::Error::Bug("invalid database path"))?;

#[cfg(not(target_os = "windows"))]
let path = std::ffi::CString::new(path.as_ref().as_os_str().as_bytes())
.map_err(|_| crate::error::Error::Bug("invalid database path"))?;

let mut conn: *mut crate::ffi::sqlite3 = std::ptr::null_mut();
// We pass a pointer to the WAL methods data to the database connection. This means
// that the reference must outlive the connection. This is guaranteed by the marker in
Expand Down
Binary file added vendored/sqlite3-parser/lemon.obj
Binary file not shown.

0 comments on commit ad4188d

Please sign in to comment.