From 061dee7e0e13249d811f3db1f1269c46719d71f4 Mon Sep 17 00:00:00 2001 From: Fumiya Funatsu Date: Fri, 12 Apr 2024 16:04:48 +0900 Subject: [PATCH] windows support --- rlottie/src/lib.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/rlottie/src/lib.rs b/rlottie/src/lib.rs index ccb681e8..9040dabd 100644 --- a/rlottie/src/lib.rs +++ b/rlottie/src/lib.rs @@ -29,11 +29,16 @@ use rgb::{alt::BGRA, RGB}; use rlottie_sys::*; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; +#[cfg(target_os = "linux")] +use std::os::unix::ffi::OsStrExt; +#[cfg(target_os = "macos")] +use std::os::unix::ffi::OsStrExt; +#[cfg(target_os = "windows")] +use std::os::windows::ffi::OsStrExt; use std::{ ffi::CString, fmt::{self, Debug}, mem, - os::unix::ffi::OsStrExt, path::Path, ptr::NonNull, slice @@ -52,7 +57,12 @@ fn path_to_cstr

(path: P) -> CString where P: AsRef { + #[cfg(target_os = "linux")] let bytes = path.as_ref().as_os_str().as_bytes().to_vec(); + #[cfg(target_os = "macos")] + let bytes = path.as_ref().as_os_str().as_bytes().to_vec(); + #[cfg(target_os = "windows")] + let bytes = path.as_ref().as_os_str().as_encoded_bytes().to_vec(); CString::new(bytes).expect("path must not contain nul") }