@@ -8,7 +8,7 @@ pub(crate) mod tray;
88
99use crate :: {
1010 api:: assets:: Assets ,
11- api:: config:: WindowUrl ,
11+ api:: config:: { Config , WindowUrl } ,
1212 hooks:: { InvokeHandler , OnPageLoad , PageLoadPayload , SetupHook } ,
1313 manager:: { Args , WindowManager } ,
1414 plugin:: { Plugin , PluginStore } ,
@@ -22,7 +22,9 @@ use crate::{
2222 Context , Invoke , Manager , StateManager , Window ,
2323} ;
2424
25- use std:: { collections:: HashMap , sync:: Arc } ;
25+ use tauri_utils:: PackageInfo ;
26+
27+ use std:: { collections:: HashMap , path:: PathBuf , sync:: Arc } ;
2628
2729#[ cfg( feature = "menu" ) ]
2830use crate :: runtime:: menu:: Menu ;
@@ -85,6 +87,25 @@ impl<P: Params> GlobalWindowEvent<P> {
8587 }
8688}
8789
90+ /// The path resolver is a helper for the application-specific [`crate::api::path`] APIs.
91+ #[ derive( Debug , Clone ) ]
92+ pub struct PathResolver {
93+ config : Arc < Config > ,
94+ package_info : PackageInfo ,
95+ }
96+
97+ impl PathResolver {
98+ /// Returns the path to the resource directory of this app.
99+ pub fn resource_dir ( & self ) -> Option < PathBuf > {
100+ crate :: api:: path:: resource_dir ( & self . package_info )
101+ }
102+
103+ /// Returns the path to the suggested directory for your app config files.
104+ pub fn app_dir ( & self ) -> Option < PathBuf > {
105+ crate :: api:: path:: app_dir ( & self . config )
106+ }
107+ }
108+
88109crate :: manager:: default_args! {
89110 /// A handle to the currently running application.
90111 ///
@@ -187,6 +208,14 @@ macro_rules! shared_app_impl {
187208 . clone( )
188209 . expect( "tray not configured; use the `Builder#system_tray` API first." )
189210 }
211+
212+ /// The path resolver for the application.
213+ pub fn path_resolver( & self ) -> PathResolver {
214+ PathResolver {
215+ config: self . manager. config( ) ,
216+ package_info: self . manager. package_info( ) . clone( ) ,
217+ }
218+ }
190219 }
191220 } ;
192221}
0 commit comments