use std::ffi::{OsStr, OsString};
#[cfg(unix)]
pub const PLATFORM_FILE_PREFIX: &str = "lib";
#[cfg(windows)]
pub const PLATFORM_FILE_PREFIX: &str = "";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub const PLATFORM_FILE_EXTENSION: &str = "dylib";
#[cfg(all(unix, not(any(target_os = "macos", target_os = "ios"))))]
pub const PLATFORM_FILE_EXTENSION: &str = "so";
#[cfg(windows)]
pub const PLATFORM_FILE_EXTENSION: &str = "dll";
pub fn platform_file_name<S>(core_name: S) -> OsString
where
S: AsRef<OsStr>,
{
let mut result = OsString::new();
result.reserve_exact(
core_name.as_ref().len() + PLATFORM_FILE_EXTENSION.len() + PLATFORM_FILE_PREFIX.len() + 1,
);
result.push(PLATFORM_FILE_PREFIX);
result.push(core_name);
result.push(".");
result.push(PLATFORM_FILE_EXTENSION);
result
}