Skip to main content

adjust_shared_library_path

Function adjust_shared_library_path 

Source
pub fn adjust_shared_library_path(path: &Path) -> Result<PathBuf, ErrReport>
Expand description

Adjusts a shared library path by adding the platform-specific prefix and suffix.

Takes a base path (without platform-specific prefix and extension) and returns a path with the appropriate shared library naming conventions using DLL_PREFIX and DLL_SUFFIX.

§Errors

Returns an error if the path has no file name, contains invalid UTF-8, already starts with lib, or already has an extension.

§Example

use std::path::Path;
use dora_core::adjust_shared_library_path;

let adjusted = adjust_shared_library_path(Path::new("mylib")).unwrap();
let expected = format!("{}mylib{}", std::env::consts::DLL_PREFIX, std::env::consts::DLL_SUFFIX);
assert_eq!(adjusted.file_name().unwrap().to_str().unwrap(), expected);