@@ -19,12 +19,21 @@ use {
19
19
use alloc:: { string:: String , string:: ToString , vec:: Vec } ;
20
20
use cstr_core:: CString ;
21
21
22
+ #[ cfg( target_os = "linux" ) ]
22
23
extern "C" {
23
24
pub fn _frida_g_get_home_dir ( ) -> * const c_char ;
24
25
pub fn _frida_g_get_current_dir ( ) -> * const c_char ;
25
26
pub fn _frida_g_get_tmp_dir ( ) -> * const c_char ;
26
27
}
27
28
29
+ #[ cfg( not( target_os = "linux" ) ) ]
30
+ extern "C" {
31
+ pub fn _g_get_home_dir ( ) -> * const c_char ;
32
+ pub fn _g_get_current_dir ( ) -> * const c_char ;
33
+ pub fn _g_get_tmp_dir ( ) -> * const c_char ;
34
+ }
35
+
36
+
28
37
#[ derive( Clone , FromPrimitive , Debug ) ]
29
38
#[ repr( u32 ) ]
30
39
pub enum CodeSigningPolicy {
@@ -121,27 +130,42 @@ impl<'a> Process<'a> {
121
130
/// Returns a string specifying the filesystem path to the current working directory
122
131
pub fn current_dir ( & self ) -> String {
123
132
unsafe {
133
+ #[ cfg( target_os = "linux" ) ]
124
134
CStr :: from_ptr ( _frida_g_get_current_dir ( ) )
125
135
. to_string_lossy ( )
126
136
. to_string ( )
137
+ #[ cfg( not( target_os = "linux" ) ) ]
138
+ CStr :: from_ptr ( _g_get_current_dir ( ) )
139
+ . to_string_lossy ( )
140
+ . to_string ( )
127
141
}
128
142
}
129
143
130
144
/// Returns a string specifying the filesystem path to the directory to use for temporary files
131
145
pub fn tmp_dir ( & self ) -> String {
132
146
unsafe {
147
+ #[ cfg( target_os = "linux" ) ]
133
148
CStr :: from_ptr ( _frida_g_get_tmp_dir ( ) )
134
149
. to_string_lossy ( )
135
150
. to_string ( )
151
+ #[ cfg( not( target_os = "linux" ) ) ]
152
+ CStr :: from_ptr ( _g_get_tmp_dir ( ) )
153
+ . to_string_lossy ( )
154
+ . to_string ( )
136
155
}
137
156
}
138
157
139
158
/// Returns a string specifying the filesystem path to the current user’s home directory
140
159
pub fn home_dir ( & self ) -> String {
141
160
unsafe {
161
+ #[ cfg( target_os = "linux" ) ]
142
162
CStr :: from_ptr ( _frida_g_get_home_dir ( ) )
143
163
. to_string_lossy ( )
144
164
. to_string ( )
165
+ #[ cfg( not( target_os = "linux" ) ) ]
166
+ CStr :: from_ptr ( _g_get_home_dir ( ) )
167
+ . to_string_lossy ( )
168
+ . to_string ( )
145
169
}
146
170
}
147
171
0 commit comments