pub fn resource_dir() -> crate::Result<PathBuf> {
  let exe = std::env::current_exe()?;
  let exe_dir = exe.parent().expect("failed to get exe directory");
  let app_name = exe
    .file_name()
    .expect("failed to get exe filename")
    .to_string_lossy();
  let curr_dir = exe_dir.display().to_string();

  if curr_dir.ends_with(format!("{S}target{S}debug", S = MAIN_SEPARATOR).as_str())
    || curr_dir.ends_with(format!("{S}target{S}release", S = MAIN_SEPARATOR).as_str())
    || cfg!(target_os = "windows")
  {
    // running from the out dir or windows
    return Ok(exe_dir.to_path_buf());
  }

  if cfg!(target_os = "linux") {
    if curr_dir.ends_with("/data/usr/bin") {
      // running from the deb bundle dir
      Ok(exe_dir.join(format!("../lib/{}", app_name)))
    } else {
      // running bundle
      Ok(PathBuf::from(format!("/usr/lib/{}", app_name)))
    }
  } else if cfg!(target_os = "macos") {
    Ok(exe_dir.join("../Resources"))
  } else {
    Err(crate::Error::UnsupportedPlatform)
  }
}
/// Computes the resource directory of the current environment.
///
/// On Windows, it's the path to the executable.
///
/// On Linux, it's `/usr/lib/${exe_name}` when running the bundled app,
/// and `${exe_dir}/../lib/${exe_name}` when running the app from `src-tauri/target/(debug|release)/`.
///
/// On MacOS, it's `${exe_dir}../Resources` (inside .app).
Computes the resource directory of the current environment.
On Windows, it's the path to the executable.




Computes the resource directory of the current environment . On Windows it ' s the path to the executable .
pub fn resource_dir() -> crate::Result<PathBuf> {
  let exe = std::env::current_exe()?;
  let exe_dir = exe.parent().expect("failed to get exe directory");
  let app_name = exe
    .file_name()
    .expect("failed to get exe filename")
    .to_string_lossy();
  let curr_dir = exe_dir.display().to_string();
  if curr_dir.ends_with(format!("{S}target{S}debug", S = MAIN_SEPARATOR).as_str())
    || curr_dir.ends_with(format!("{S}target{S}release", S = MAIN_SEPARATOR).as_str())
    || cfg!(target_os = "windows")
  {
    // running from the out dir or windows
    return Ok(exe_dir.to_path_buf());
  }
  if cfg!(target_os = "linux") {
    if curr_dir.ends_with("/data/usr/bin") {
      // running from the deb bundle dir
      Ok(exe_dir.join(format!("../lib/{}", app_name)))
    } else {
      // running bundle
      Ok(PathBuf::from(format!("/usr/lib/{}", app_name)))
    }
  } else if cfg!(target_os = "macos") {
    Ok(exe_dir.join("../Resources"))
  } else {
    Err(crate::Error::UnsupportedPlatform)
  }
}
pub fn resource_dir ( ) -> crate :: Result < PathBuf > { let exe = std :: env :: current_exe ( ) ? ; let exe_dir = exe . parent ( ) . expect ( " " ) ; let app_name = exe . file_name ( ) . expect ( " " ) . to_string_lossy ( ) ; let curr_dir = exe_dir . display ( ) . to_string ( ) ; if curr_dir . ends_with ( format ! ( " " S MAIN_SEPARATOR ) . as_str ( ) ) || curr_dir . ends_with ( format ! ( " " S MAIN_SEPARATOR ) . as_str ( ) ) || cfg ! ( target_os " " ) { // running from the out dir or windows return Ok ( exe_dir . to_path_buf ( ) ) ; } if cfg ! ( target_os " " ) { if curr_dir . ends_with ( " " ) { // running from the deb bundle dir Ok ( exe_dir . join ( format ! ( " " app_name ) ) ) } else { // running bundle Ok ( PathBuf :: from ( format ! ( " " app_name ) ) ) } } else if cfg ! ( target_os " " ) { Ok ( exe_dir . join ( " " ) ) } else { Err ( crate :: Error :: UnsupportedPlatform ) } }
Computes the resource directory of the current environment.
Computes the resource directory of the current environment .