pub fn resolve_path<P: AsRef<Path>>(path: P, dir: Option<BaseDirectory>) -> crate::Result<PathBuf> {
  if let Some(base_dir) = dir {
    let base_dir_path = match base_dir {
      BaseDirectory::Audio => audio_dir(),
      BaseDirectory::Cache => cache_dir(),
      BaseDirectory::Config => config_dir(),
      BaseDirectory::Data => data_dir(),
      BaseDirectory::LocalData => local_data_dir(),
      BaseDirectory::Desktop => desktop_dir(),
      BaseDirectory::Document => document_dir(),
      BaseDirectory::Download => download_dir(),
      BaseDirectory::Executable => executable_dir(),
      BaseDirectory::Font => font_dir(),
      BaseDirectory::Home => home_dir(),
      BaseDirectory::Picture => picture_dir(),
      BaseDirectory::Public => public_dir(),
      BaseDirectory::Runtime => runtime_dir(),
      BaseDirectory::Template => template_dir(),
      BaseDirectory::Video => video_dir(),
      BaseDirectory::Resource => resource_dir(),
      BaseDirectory::App => app_dir(),
    };
    if let Some(mut base_dir_path_value) = base_dir_path {
      base_dir_path_value.push(path);
      Ok(base_dir_path_value)
    } else {
      Err(crate::Error::Path(
        "unable to determine base dir path".to_string(),
      ))
    }
  } else {
    let mut dir_path = PathBuf::new();
    dir_path.push(path);
    Ok(dir_path)
  }
}
/// Resolves the path with the optional base directory.
///
/// # Example
/// ```
/// use tauri_api::path::{resolve_path, BaseDirectory};
/// let path = resolve_path("path/to/something", Some(BaseDirectory::Config))
///   .expect("failed to resolve path");
/// // path is equal to "/home/${whoami}/.config/path/to/something" on Linux
/// ```
Resolves the path with the optional base directory.
Resolves the path with the optional base directory .
pub fn resolve_path<P: AsRef<Path>>(path: P, dir: Option<BaseDirectory>) -> crate::Result<PathBuf> {
  if let Some(base_dir) = dir {
    let base_dir_path = match base_dir {
      BaseDirectory::Audio => audio_dir(),
      BaseDirectory::Cache => cache_dir(),
      BaseDirectory::Config => config_dir(),
      BaseDirectory::Data => data_dir(),
      BaseDirectory::LocalData => local_data_dir(),
      BaseDirectory::Desktop => desktop_dir(),
      BaseDirectory::Document => document_dir(),
      BaseDirectory::Download => download_dir(),
      BaseDirectory::Executable => executable_dir(),
      BaseDirectory::Font => font_dir(),
      BaseDirectory::Home => home_dir(),
      BaseDirectory::Picture => picture_dir(),
      BaseDirectory::Public => public_dir(),
      BaseDirectory::Runtime => runtime_dir(),
      BaseDirectory::Template => template_dir(),
      BaseDirectory::Video => video_dir(),
      BaseDirectory::Resource => resource_dir(),
      BaseDirectory::App => app_dir(),
    };
    if let Some(mut base_dir_path_value) = base_dir_path {
      base_dir_path_value.push(path);
      Ok(base_dir_path_value)
    } else {
      Err(crate::Error::Path(
        "unable to determine base dir path".to_string(),
      ))
    }
  } else {
    let mut dir_path = PathBuf::new();
    dir_path.push(path);
    Ok(dir_path)
  }
}
pub fn resolve_path < P : AsRef < Path > > ( path : P , dir : Option < BaseDirectory > ) -> crate :: Result < PathBuf > { if let Some ( base_dir ) = dir { let base_dir_path = match base_dir { BaseDirectory :: Audio => audio_dir ( ) , BaseDirectory :: Cache => cache_dir ( ) , BaseDirectory :: Config => config_dir ( ) , BaseDirectory :: Data => data_dir ( ) , BaseDirectory :: LocalData => local_data_dir ( ) , BaseDirectory :: Desktop => desktop_dir ( ) , BaseDirectory :: Document => document_dir ( ) , BaseDirectory :: Download => download_dir ( ) , BaseDirectory :: Executable => executable_dir ( ) , BaseDirectory :: Font => font_dir ( ) , BaseDirectory :: Home => home_dir ( ) , BaseDirectory :: Picture => picture_dir ( ) , BaseDirectory :: Public => public_dir ( ) , BaseDirectory :: Runtime => runtime_dir ( ) , BaseDirectory :: Template => template_dir ( ) , BaseDirectory :: Video => video_dir ( ) , BaseDirectory :: Resource => resource_dir ( ) , BaseDirectory :: App => app_dir ( ) , } ; if let Some ( mut base_dir_path_value ) = base_dir_path { base_dir_path_value . push ( path ) ; Ok ( base_dir_path_value ) } else { Err ( crate :: Error :: Path ( " " . to_string ( ) , ) ) } } else { let mut dir_path = PathBuf :: new ( ) ; dir_path . push ( path ) ; Ok ( dir_path ) } }
Resolves the path with the optional base directory.
Resolves the path with the optional base directory .
path
P
dir
Option<BaseDirectory>
path
P
dir
Option<BaseDirectory>
example
```
use tauri_api::path::{resolve_path, BaseDirectory};
let path = resolve_path("path/to/something", Some(BaseDirectory::Config))
.expect("failed to resolve path");
path is equal to "/home/${whoami}/.config/path/to/something" on Linux
```
` ` ` use tauri_api :: path :: { resolve_path BaseDirectory } ; let path = resolve_path ( " path / to / something " Some ( BaseDirectory :: Config )) . expect ( " failed to resolve path " ) ; path is equal to " / home / $ { whoami } / . config / path / to / something " on Linux ` ` `