@@ -55,9 +55,9 @@ fn enter_recursive_dir_entries(
55
55
. unwrap_or_else ( || path_to_string ( root) . into ( ) )
56
56
. trim_end_matches ( '/' )
57
57
. to_string ( ) ;
58
- write ! (
58
+ writeln ! (
59
59
err,
60
- "writing top-level directory entry for {base_dirname:?}\n "
60
+ "writing top-level directory entry for {base_dirname:?}"
61
61
) ?;
62
62
writer. add_directory ( & base_dirname, options) ?;
63
63
@@ -78,29 +78,26 @@ fn enter_recursive_dir_entries(
78
78
let file_type = dir_entry. file_type ( ) ?;
79
79
if file_type. is_symlink ( ) {
80
80
let target: String = path_to_string ( fs:: read_link ( dir_entry. path ( ) ) ?) . into ( ) ;
81
- write ! (
81
+ writeln ! (
82
82
err,
83
- "writing recursive symlink entry with name {full_path:?} and target {target:?}\n "
83
+ "writing recursive symlink entry with name {full_path:?} and target {target:?}"
84
84
) ?;
85
85
writer. add_symlink ( full_path, target, options) ?;
86
86
} else if file_type. is_file ( ) {
87
- write ! (
88
- err,
89
- "writing recursive file entry with name {full_path:?}\n "
90
- ) ?;
87
+ writeln ! ( err, "writing recursive file entry with name {full_path:?}" ) ?;
91
88
writer. start_file ( full_path, options) ?;
92
89
let mut f = fs:: File :: open ( dir_entry. path ( ) ) ?;
93
90
io:: copy ( & mut f, writer) ?;
94
91
} else {
95
92
assert ! ( file_type. is_dir( ) ) ;
96
- write ! (
93
+ writeln ! (
97
94
err,
98
- "writing recursive directory entry with name {full_path:?}\n "
95
+ "writing recursive directory entry with name {full_path:?}"
99
96
) ?;
100
97
writer. add_directory ( full_path, options) ?;
101
- write ! (
98
+ writeln ! (
102
99
err,
103
- "adding subdirectories depth-first for recursive directory entry {entry_basename:?}\n "
100
+ "adding subdirectories depth-first for recursive directory entry {entry_basename:?}"
104
101
) ?;
105
102
let new_readdir = fs:: read_dir ( dir_entry. path ( ) ) ?;
106
103
readdir_stack. push ( ( new_readdir, entry_basename) ) ;
@@ -123,13 +120,13 @@ pub fn execute_compress(
123
120
124
121
let out = match output_path {
125
122
Some ( path) => {
126
- write ! ( err, "writing compressed zip to output file path {path:?}\n " ) ?;
123
+ writeln ! ( err, "writing compressed zip to output file path {path:?}" ) ?;
127
124
OutputHandle :: File ( fs:: File :: create ( path) ?)
128
125
}
129
126
None => {
130
- write ! (
127
+ writeln ! (
131
128
err,
132
- "writing to stdout and buffering compressed zip in memory\n "
129
+ "writing to stdout and buffering compressed zip in memory"
133
130
) ?;
134
131
if io:: stdout ( ) . is_terminal ( ) && !allow_stdout {
135
132
return Err ( eyre ! ( "stdout is a tty, but --stdout was not set" ) ) ;
@@ -142,7 +139,7 @@ pub fn execute_compress(
142
139
let mut options = SimpleFileOptions :: default ( )
143
140
. compression_method ( CompressionMethod :: Deflated )
144
141
. large_file ( false ) ;
145
- write ! ( err, "default zip entry options: {options:?}\n " ) ?;
142
+ writeln ! ( err, "default zip entry options: {options:?}" ) ?;
146
143
let mut last_name: Option < String > = None ;
147
144
let mut symlink_flag: bool = false ;
148
145
@@ -152,27 +149,30 @@ pub fn execute_compress(
152
149
let method = match method {
153
150
CompressionMethodArg :: Stored => CompressionMethod :: Stored ,
154
151
CompressionMethodArg :: Deflate => CompressionMethod :: Deflated ,
152
+ #[ cfg( feature = "deflate64" ) ]
155
153
CompressionMethodArg :: Deflate64 => CompressionMethod :: Deflate64 ,
154
+ #[ cfg( feature = "bzip2" ) ]
156
155
CompressionMethodArg :: Bzip2 => CompressionMethod :: Bzip2 ,
156
+ #[ cfg( feature = "zstd" ) ]
157
157
CompressionMethodArg :: Zstd => CompressionMethod :: Zstd ,
158
158
} ;
159
- write ! ( err, "setting compression method {method:?}\n " ) ?;
159
+ writeln ! ( err, "setting compression method {method:?}" ) ?;
160
160
options = options. compression_method ( method) ;
161
161
}
162
162
CompressionArg :: Level ( CompressionLevel ( level) ) => {
163
- write ! ( err, "setting compression level {level:?}\n " ) ?;
163
+ writeln ! ( err, "setting compression level {level:?}" ) ?;
164
164
options = options. compression_level ( Some ( level) ) ;
165
165
}
166
166
CompressionArg :: Mode ( Mode ( mode) ) => {
167
- write ! ( err, "setting file mode {mode:#o}\n " ) ?;
167
+ writeln ! ( err, "setting file mode {mode:#o}" ) ?;
168
168
options = options. unix_permissions ( mode) ;
169
169
}
170
170
CompressionArg :: LargeFile ( large_file) => {
171
- write ! ( err, "setting large file flag to {large_file:?}\n " ) ?;
171
+ writeln ! ( err, "setting large file flag to {large_file:?}" ) ?;
172
172
options = options. large_file ( large_file) ;
173
173
}
174
174
CompressionArg :: Name ( name) => {
175
- write ! ( err, "setting name of next entry to {name:?}\n " ) ?;
175
+ writeln ! ( err, "setting name of next entry to {name:?}" ) ?;
176
176
if let Some ( last_name) = last_name {
177
177
return Err ( eyre ! (
178
178
"got two names before an entry: {last_name} and {name}"
@@ -181,7 +181,7 @@ pub fn execute_compress(
181
181
last_name = Some ( name) ;
182
182
}
183
183
CompressionArg :: Dir => {
184
- write ! ( err, "writing dir entry\n " ) ?;
184
+ writeln ! ( err, "writing dir entry" ) ?;
185
185
if symlink_flag {
186
186
return Err ( eyre ! ( "symlink flag provided before dir entry with " ) ) ;
187
187
}
@@ -191,7 +191,7 @@ pub fn execute_compress(
191
191
writer. add_directory ( dirname, options) ?;
192
192
}
193
193
CompressionArg :: Symlink => {
194
- write ! ( err, "setting symlink flag for next entry\n " ) ?;
194
+ writeln ! ( err, "setting symlink flag for next entry" ) ?;
195
195
if symlink_flag {
196
196
/* TODO: make this a warning? */
197
197
return Err ( eyre ! ( "symlink flag provided twice before entry" ) ) ;
@@ -207,18 +207,18 @@ pub fn execute_compress(
207
207
let target = data
208
208
. into_string ( )
209
209
. map_err ( |target| eyre ! ( "failed to decode symlink target {target:?}" ) ) ?;
210
- write ! (
210
+ writeln ! (
211
211
err,
212
- "writing immediate symlink entry with name {name:?} and target {target:?}\n "
212
+ "writing immediate symlink entry with name {name:?} and target {target:?}"
213
213
) ?;
214
214
/* TODO: .add_symlink() should support OsString targets! */
215
215
writer. add_symlink ( name, target, options) ?;
216
216
symlink_flag = false ;
217
217
} else {
218
218
/* This is a file entry. */
219
- write ! (
219
+ writeln ! (
220
220
err,
221
- "writing immediate file entry with name {name:?} and data {data:?}\n "
221
+ "writing immediate file entry with name {name:?} and data {data:?}"
222
222
) ?;
223
223
let data = data. into_encoded_bytes ( ) ;
224
224
writer. start_file ( name, options) ?;
@@ -232,14 +232,14 @@ pub fn execute_compress(
232
232
if symlink_flag {
233
233
/* This is a symlink entry. */
234
234
let target: String = path_to_string ( fs:: read_link ( & path) ?) . into ( ) ;
235
- write ! ( err, "writing symlink entry from path {path:?} with name {name:?} and target {target:?}\n " ) ?;
235
+ writeln ! ( err, "writing symlink entry from path {path:?} with name {name:?} and target {target:?}" ) ?;
236
236
writer. add_symlink ( name, target, options) ?;
237
237
symlink_flag = false ;
238
238
} else {
239
239
/* This is a file entry. */
240
- write ! (
240
+ writeln ! (
241
241
err,
242
- "writing file entry from path {path:?} with name {name:?}\n "
242
+ "writing file entry from path {path:?} with name {name:?}"
243
243
) ?;
244
244
writer. start_file ( name, options) ?;
245
245
let mut f = fs:: File :: open ( path) ?;
@@ -250,9 +250,9 @@ pub fn execute_compress(
250
250
if symlink_flag {
251
251
return Err ( eyre ! ( "symlink flag provided before recursive dir entry" ) ) ;
252
252
}
253
- write ! (
253
+ writeln ! (
254
254
err,
255
- "writing recursive dir entries for path {r:?} with name {last_name:?}\n "
255
+ "writing recursive dir entries for path {r:?} with name {last_name:?}"
256
256
) ?;
257
257
enter_recursive_dir_entries ( err, last_name. take ( ) , & r, & mut writer, options) ?;
258
258
}
@@ -272,21 +272,21 @@ pub fn execute_compress(
272
272
let file_type = fs:: symlink_metadata ( & pos_arg) ?. file_type ( ) ;
273
273
if file_type. is_symlink ( ) {
274
274
let target = fs:: read_link ( & pos_arg) ?;
275
- write ! (
275
+ writeln ! (
276
276
err,
277
- "writing positional symlink entry with path {pos_arg:?} and target {target:?}\n "
277
+ "writing positional symlink entry with path {pos_arg:?} and target {target:?}"
278
278
) ?;
279
279
writer. add_symlink_from_path ( pos_arg, target, options) ?;
280
280
} else if file_type. is_file ( ) {
281
- write ! ( err, "writing positional file entry with path {pos_arg:?}\n " ) ?;
281
+ writeln ! ( err, "writing positional file entry with path {pos_arg:?}" ) ?;
282
282
writer. start_file_from_path ( & pos_arg, options) ?;
283
283
let mut f = fs:: File :: open ( pos_arg) ?;
284
284
io:: copy ( & mut f, & mut writer) ?;
285
285
} else {
286
286
assert ! ( file_type. is_dir( ) ) ;
287
- write ! (
287
+ writeln ! (
288
288
err,
289
- "writing positional recursive dir entry for {pos_arg:?}\n "
289
+ "writing positional recursive dir entry for {pos_arg:?}"
290
290
) ?;
291
291
enter_recursive_dir_entries ( err, None , & pos_arg, & mut writer, options) ?;
292
292
}
0 commit comments