From 53bf0e53d1a4f9a6e68167e306db3dce0edabd1e Mon Sep 17 00:00:00 2001 From: Ziyang Hu Date: Tue, 10 Jan 2023 13:03:16 +0800 Subject: [PATCH] fix RocksDB path on windows --- cozorocks/src/bridge/db.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/cozorocks/src/bridge/db.rs b/cozorocks/src/bridge/db.rs index 7857c7dc..f65998c1 100644 --- a/cozorocks/src/bridge/db.rs +++ b/cozorocks/src/bridge/db.rs @@ -20,16 +20,8 @@ pub struct DbBuilder { fn path2buf(path: impl AsRef) -> Vec { #[cfg(target_os = "windows")] { - use std::os::windows::ffi::OsStrExt; - path.as_ref() - .as_os_str() - .encode_wide() - .map(|b| { - let b = b.to_ne_bytes(); - b.get(0).map(|s| *s).into_iter().chain(b.get(1).map(|s| *s)) - }) - .flatten() - .collect::>() + // It seems RocksDB expects UTF-8 strings as path even in Windows! + path.as_ref().to_string_lossy().as_bytes().to_vec() } #[cfg(not(target_os = "windows"))] {