[][src]Struct winepath::WineConfig

pub struct WineConfig { /* fields omitted */ }

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]

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]

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

impl Debug for WineConfig[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]