@@ -19,9 +19,9 @@ impl Apk {
1919 let mut buffer = Vec :: new ( ) ;
2020 let file = std:: fs:: File :: open ( & path) ?;
2121 let mut zip_handler = ZipArchive :: new ( file) ?;
22- zip_handler
23- . by_name ( "resources.arsc" ) ?
24- . read_to_end ( & mut buffer ) ?;
22+ zip_handler. by_name ( "resources.arsc" ) ? . read_to_end (
23+ & mut buffer ,
24+ ) ?;
2525
2626 let apk = Apk {
2727 handler : zip_handler,
@@ -34,40 +34,43 @@ impl Apk {
3434 /// It exports to target output_path the contents of the APK, transcoding the binary XML files
3535 /// found on it.
3636 pub fn export < P : AsRef < Path > > ( & mut self , output_path : P , force : bool ) -> Result < ( ) > {
37- let decoder = self . decoder
38- . get_decoder ( )
39- . chain_err ( || "Could not get the decoder" ) ?;
37+ let decoder = self . decoder . get_decoder ( ) . chain_err (
38+ || "Could not get the decoder" ,
39+ ) ?;
4040
4141 if fs:: create_dir_all ( & output_path) . is_err ( ) && force {
42- fs:: remove_dir_all ( & output_path)
43- . chain_err ( || {
44- format ! ( "Could not clean target directory: {}" ,
45- output_path. as_ref( ) . display( ) )
46- } ) ?;
47- fs:: create_dir_all ( & output_path)
48- . chain_err ( || {
49- format ! ( "Error creating the output folder: {}" ,
50- output_path. as_ref( ) . display( ) )
51- } ) ?;
42+ fs:: remove_dir_all ( & output_path) . chain_err ( || {
43+ format ! (
44+ "Could not clean target directory: {}" ,
45+ output_path. as_ref( ) . display( )
46+ )
47+ } ) ?;
48+ fs:: create_dir_all ( & output_path) . chain_err ( || {
49+ format ! (
50+ "Error creating the output folder: {}" ,
51+ output_path. as_ref( ) . display( )
52+ )
53+ } ) ?;
5254 }
5355
5456 // Iterate over all the files on the ZIP and extract them
5557 for i in 0 ..self . handler . len ( ) {
5658 let ( file_name, contents) = {
57- let mut current_file = self . handler
58- . by_index ( i )
59- . chain_err ( || "Could not read ZIP entry" ) ?;
59+ let mut current_file = self . handler . by_index ( i ) . chain_err (
60+ || "Could not read ZIP entry" ,
61+ ) ?;
6062 let mut contents = Vec :: new ( ) ;
61- current_file
62- . read_to_end ( & mut contents )
63- . chain_err ( || format ! ( "Could not read: {}" , current_file . name ( ) ) ) ?;
63+ current_file. read_to_end ( & mut contents ) . chain_err ( || {
64+ format ! ( "Could not read: {}" , current_file . name ( ) )
65+ } ) ?;
6466 let is_xml = current_file. name ( ) . to_string ( ) ;
6567
6668 ( is_xml, contents)
6769 } ;
6870
6971 let contents = if ( file_name. starts_with ( "res/" ) && file_name. ends_with ( ".xml" ) ) ||
70- file_name == "AndroidManifest.xml" {
72+ file_name == "AndroidManifest.xml"
73+ {
7174
7275 decoder
7376 . xml_visitor ( & contents)
@@ -86,24 +89,26 @@ impl Apk {
8689 Ok ( ( ) )
8790 }
8891
89- fn write_file < B : AsRef < Path > , R : AsRef < Path > > ( base_path : B ,
90- relative : R ,
91- content : & [ u8 ] )
92- -> Result < ( ) > {
92+ fn write_file < B : AsRef < Path > , R : AsRef < Path > > (
93+ base_path : B ,
94+ relative : R ,
95+ content : & [ u8 ] ,
96+ ) -> Result < ( ) > {
9397 let full_path = base_path. as_ref ( ) . join ( & relative) ;
9498 // println!("Full path: {}", full_path.display());
95- fs:: create_dir_all ( full_path. parent ( ) . unwrap ( ) )
96- . chain_err ( || "Could not create the output dir" ) ?;
99+ fs:: create_dir_all ( full_path. parent ( ) . unwrap ( ) ) . chain_err (
100+ || "Could not create the output dir" ,
101+ ) ?;
97102
98103 let mut descriptor = fs:: OpenOptions :: new ( )
99104 . write ( true )
100105 . create_new ( true )
101106 . open ( full_path)
102107 . chain_err ( || "Could not open file to write" ) ?;
103108
104- descriptor
105- . write_all ( content )
106- . chain_err ( || "Could not write to target file" ) ?;
109+ descriptor. write_all ( content ) . chain_err (
110+ || "Could not write to target file" ,
111+ ) ?;
107112
108113 Ok ( ( ) )
109114 }
0 commit comments