@@ -14,7 +14,7 @@ use crate::file_format::macho;
1414#[ cfg( feature = "alloc" ) ]
1515use alloc:: vec:: Vec ;
1616#[ cfg( feature = "alloc" ) ]
17- use std:: { path :: Path , fs:: File , io, io:: Read } ;
17+ use std:: { fs:: File , io, io:: Read } ;
1818
1919#[ cfg( feature = "derive" ) ]
2020pub use asr_derive:: MonoClass as Class ;
@@ -143,9 +143,9 @@ impl Module {
143143 let offsets = Offsets :: new ( version, is_64_bit, BinaryFormat :: MachO ) ;
144144
145145 let process_path = process. get_path ( ) . ok ( ) ?;
146- let contents_path = Path :: new ( path_parent ( path_parent ( & process_path) ?) ?) ;
147- let mono_module_path = contents_path . join ( "Frameworks" ) . join ( "libmonobdwgc-2.0.dylib" ) ;
148- let mono_module_bytes = file_read_all_bytes ( mono_module_path) . ok ( ) ?;
146+ let contents_path = path_parent ( path_parent ( & process_path) ?) ?;
147+ let mono_module_path = path_join ( & path_join ( contents_path , "Frameworks" ) , "libmonobdwgc-2.0.dylib" ) ;
148+ let mono_module_bytes = file_read_all_bytes ( & mono_module_path) . ok ( ) ?;
149149
150150 let mono_assembly_foreach_offset: u32 = macho:: get_function_offset ( & mono_module_bytes, b"_mono_assembly_foreach" ) ?;
151151
@@ -832,9 +832,9 @@ fn detect_version_dylib(process: &Process) -> Option<Version> {
832832 const UNITY_PLAYER_VERSION_LEN : usize = UNITY_PLAYER_VERSION . len ( ) ;
833833
834834 let process_path = process. get_path ( ) . ok ( ) ?;
835- let contents_path = Path :: new ( path_parent ( path_parent ( & process_path) ?) ?) ;
836- let info_plist_path = contents_path . join ( "Info.plist" ) ;
837- let info_plist_bytes = file_read_all_bytes ( info_plist_path) . ok ( ) ?;
835+ let contents_path = path_parent ( path_parent ( & process_path) ?) ?;
836+ let info_plist_path = path_join ( contents_path , "Info.plist" ) ;
837+ let info_plist_bytes = file_read_all_bytes ( & info_plist_path) . ok ( ) ?;
838838 // example: "Unity Player version 2020.2.2f1 "
839839 let upv = memchr:: memmem:: find ( & info_plist_bytes, UNITY_PLAYER_VERSION ) ?;
840840 let version_string: ArrayCString < 6 > = macho:: slice_read ( & info_plist_bytes, upv + UNITY_PLAYER_VERSION_LEN ) . ok ( ) ?;
@@ -886,7 +886,12 @@ fn path_parent(path: &str) -> Option<&str> {
886886}
887887
888888#[ cfg( feature = "alloc" ) ]
889- fn file_read_all_bytes < P : AsRef < Path > > ( path : P ) -> io:: Result < Vec < u8 > > {
889+ fn path_join ( base : & str , sub : & str ) -> String {
890+ format ! ( "{}/{}" , base, sub)
891+ }
892+
893+ #[ cfg( feature = "alloc" ) ]
894+ fn file_read_all_bytes ( path : & str ) -> io:: Result < Vec < u8 > > {
890895 let mut f = File :: open ( path) ?;
891896 let mut buffer: Vec < u8 > = Vec :: new ( ) ;
892897 f. read_to_end ( & mut buffer) ?;
0 commit comments