Skip to main content

resource_dir

Function resource_dir 

Source
pub fn resource_dir(package_info: &PackageInfo, env: &Env) -> Result<PathBuf>
Expand description

Computes the resource directory of the current environment.

§Platform-specific

  • Windows: Resolves to the directory that contains the main executable.
  • Linux: When running in an AppImage, the APPDIR variable will be set to the mounted location of the app, and the resource dir will be ${APPDIR}/usr/lib/${exe_name}. If not running in an AppImage, the path is /usr/lib/${exe_name}. When running the app from src-tauri/target/(debug|release)/, the path is ${exe_dir}/../lib/${exe_name}.
  • macOS: Resolves to ${exe_dir}/../Resources (inside .app).
  • iOS: Resolves to ${exe_dir}/assets.
  • Android: Currently the resources are stored in the APK as assets so it’s not a normal file system path, we return a special URI prefix asset://localhost/ here that can be used with the file system plugin, with that, you can read the files through FsExt::fs like this: app.fs().read_to_string(app.path().resource_dir().unwrap().join("resource"));