@@ -644,12 +644,12 @@ void write_lldb_prep_cmds(AMDeviceRef device, CFURLRef disk_app_url) {
644
644
if (args ) {
645
645
CFStringRef cf_args = CFStringCreateWithCString (NULL , args , kCFStringEncodingASCII );
646
646
CFStringFindAndReplace (cmds , CFSTR ("{args}" ), cf_args , range , 0 );
647
- rangeLLDB .length = CFStringGetLength (pmodule );
648
647
CFStringFindAndReplace (pmodule , CFSTR ("{args}" ), cf_args , rangeLLDB , 0 );
649
648
650
649
CFRelease (cf_args );
651
650
} else {
652
- CFStringFindAndReplace (cmds , CFSTR (" {args}" ), CFSTR ("" ), range , 0 );
651
+ CFStringFindAndReplace (cmds , CFSTR ("{args}" ), CFSTR ("" ), range , 0 );
652
+ CFStringFindAndReplace (pmodule , CFSTR ("{args}" ), CFSTR ("" ), rangeLLDB , 0 );
653
653
}
654
654
range .length = CFStringGetLength (cmds );
655
655
@@ -1002,7 +1002,8 @@ CFStringRef get_bundle_id(CFURLRef app_url)
1002
1002
return bundle_id ;
1003
1003
}
1004
1004
1005
- void read_dir (service_conn_t afcFd , afc_connection * afc_conn_p , const char * dir )
1005
+ void read_dir (service_conn_t afcFd , afc_connection * afc_conn_p , const char * dir ,
1006
+ void (* callback )(afc_connection * conn ,const char * dir ,int file ))
1006
1007
{
1007
1008
char * dir_ent ;
1008
1009
@@ -1014,24 +1015,38 @@ void read_dir(service_conn_t afcFd, afc_connection* afc_conn_p, const char* dir)
1014
1015
1015
1016
printf ("%s\n" , dir );
1016
1017
1017
- afc_dictionary afc_dict ;
1018
- afc_dictionary * afc_dict_p = & afc_dict ;
1018
+ afc_dictionary * afc_dict_p ;
1019
+ char * key , * val ;
1020
+ int not_dir ;
1021
+
1019
1022
AFCFileInfoOpen (afc_conn_p , dir , & afc_dict_p );
1020
-
1021
- afc_directory afc_dir ;
1022
- afc_directory * afc_dir_p = & afc_dir ;
1023
+ while ((AFCKeyValueRead (afc_dict_p ,& key ,& val ) == 0 ) && key && val ) {
1024
+ if (strcmp (key ,"st_ifmt" )== 0 ) {
1025
+ not_dir = strcmp (val ,"S_IFDIR" );
1026
+ break ;
1027
+ }
1028
+ }
1029
+ AFCKeyValueClose (afc_dict_p );
1030
+
1031
+ if (not_dir ) {
1032
+ if (callback ) (* callback )(afc_conn_p , dir , not_dir );
1033
+ return ;
1034
+ }
1035
+
1036
+ afc_directory * afc_dir_p ;
1023
1037
afc_error_t err = AFCDirectoryOpen (afc_conn_p , dir , & afc_dir_p );
1024
1038
1025
- if (err != 0 )
1026
- {
1039
+ if (err != 0 ) {
1027
1040
// Couldn't open dir - was probably a file
1028
1041
return ;
1042
+ } else {
1043
+ if (callback ) (* callback )(afc_conn_p , dir , not_dir );
1029
1044
}
1030
1045
1031
1046
while (true) {
1032
1047
err = AFCDirectoryRead (afc_conn_p , afc_dir_p , & dir_ent );
1033
1048
1034
- if (!dir_ent )
1049
+ if (err != 0 || !dir_ent )
1035
1050
break ;
1036
1051
1037
1052
if (strcmp (dir_ent , "." ) == 0 || strcmp (dir_ent , ".." ) == 0 )
@@ -1042,7 +1057,7 @@ void read_dir(service_conn_t afcFd, afc_connection* afc_conn_p, const char* dir)
1042
1057
if (dir_joined [strlen (dir )- 1 ] != '/' )
1043
1058
strcat (dir_joined , "/" );
1044
1059
strcat (dir_joined , dir_ent );
1045
- read_dir (afcFd , afc_conn_p , dir_joined );
1060
+ read_dir (afcFd , afc_conn_p , dir_joined , callback );
1046
1061
free (dir_joined );
1047
1062
}
1048
1063
@@ -1119,11 +1134,11 @@ void list_files(AMDeviceRef device)
1119
1134
{
1120
1135
service_conn_t houseFd = start_house_arrest_service (device );
1121
1136
1122
- afc_connection afc_conn ;
1123
- afc_connection * afc_conn_p = & afc_conn ;
1124
- AFCConnectionOpen (houseFd , 0 , & afc_conn_p );
1125
-
1126
- read_dir ( houseFd , afc_conn_p , "/" );
1137
+ afc_connection * afc_conn_p ;
1138
+ if ( AFCConnectionOpen ( houseFd , 0 , & afc_conn_p ) == 0 ) {
1139
+ read_dir (houseFd , afc_conn_p , "/" , NULL );
1140
+ AFCConnectionClose ( afc_conn_p );
1141
+ }
1127
1142
}
1128
1143
1129
1144
void upload_file (AMDeviceRef device ) {
@@ -1135,7 +1150,7 @@ void upload_file(AMDeviceRef device) {
1135
1150
afc_connection * afc_conn_p = & afc_conn ;
1136
1151
AFCConnectionOpen (houseFd , 0 , & afc_conn_p );
1137
1152
1138
- // read_dir(houseFd, NULL, "/");
1153
+ // read_dir(houseFd, NULL, "/", NULL );
1139
1154
1140
1155
if (!target_filename )
1141
1156
{
0 commit comments