[−][src]Struct winepath::WineConfig
The main conversion struct: create one of these to do conversions.
Tracks the WINEPREFIX and the drive letter mappings so they don't have to be recomputed every time you convert a path.
Methods
impl WineConfig
[src]
pub fn from_env() -> Result<Self, WinePathError>
[src]
Determine the wine prefix from the environment.
pub fn from_prefix(path: impl Into<PathBuf>) -> Self
[src]
Create a config assuming that the given path is a valid WINEPREFIX.
Note that this is not validated, and you will end up with empty drive mappings if it is not actually a wine prefix.
You can manually validate if a directory is Wine-y enough by doing:
ⓘThis example is not tested
use std::path::Path; fn is_wineprefix_like(some_path: &Path) -> bool { some_path.join("dosdevices").is_dir() }
pub fn prefix(&self) -> &Path
[src]
Get the current wine prefix.
pub fn to_wine_path(
&self,
path: impl AsRef<Path>
) -> Result<WinePath, WinePathError>
[src]
&self,
path: impl AsRef<Path>
) -> Result<WinePath, WinePathError>
Convert a native file path to a Wine path.
use winepath::WineConfig; let config = WineConfig::from_env().unwrap(); let path = config.to_wine_path("/home/username/.wine/drive_c/Program Files/CoolApp/start.exe").unwrap(); assert_eq!(path.to_string(), r"c:\Program Files\CoolApp\start.exe"); let path = config.to_wine_path("/home/username/some-path/some-file").unwrap(); assert_eq!(path.to_string(), r"z:\home\username\some-path\some-file");
pub fn to_native_path(
&self,
path: impl Into<WinePath>
) -> Result<PathBuf, WinePathError>
[src]
&self,
path: impl Into<WinePath>
) -> Result<PathBuf, WinePathError>
Convert a Wine path to a native file path.
use winepath::WineConfig; use std::path::PathBuf; let config = WineConfig::from_env().unwrap(); let path = config.to_native_path(r"c:\Program Files\CoolApp\start.exe").unwrap(); assert_eq!(path, PathBuf::from("/home/username/.wine/drive_c/Program Files/CoolApp/start.exe")); let path = config.to_native_path(r"z:\home\username\some-path\some-file").unwrap(); assert_eq!(path, PathBuf::from("/home/username/some-path/some-file"));
Trait Implementations
Auto Trait Implementations
impl Send for WineConfig
impl Sync for WineConfig
impl Unpin for WineConfig
impl UnwindSafe for WineConfig
impl RefUnwindSafe for WineConfig
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,