@@ -34,7 +34,12 @@ use crate::terminal::{as_terminal_escaped, to_ansi_color};
3434use crate::Config;
3535
3636pub trait Printer {
37− fn print_header(&mut self, handle: &mut dyn Write, file: InputFile) -> Result<()>;
37+ fn print_header(
38+ &mut self,
39+ handle: &mut dyn Write,
40+ file: InputFile,
41+ file_name: Option<&str>,
42+ ) -> Result<()>;
3843 fn print_footer(&mut self, handle: &mut dyn Write) -> Result<()>;
3944
4045 fn print_snip(&mut self, handle: &mut dyn Write) -> Result<()>;
@@ -57,7 +62,12 @@ impl SimplePrinter {
5762}
5863
5964impl Printer for SimplePrinter {
60− fn print_header(&mut self, _handle: &mut dyn Write, _file: InputFile) -> Result<()> {
65+ fn print_header(
66+ &mut self,
67+ _handle: &mut dyn Write,
68+ _file: InputFile,
69+ _file_name: Option<&str>,
70+ ) -> Result<()> {
6171 Ok(())
6272 }
6373
@@ -224,15 +234,20 @@ impl<'a> InteractivePrinter<'a> {
224234}
225235
226236impl<'a> Printer for InteractivePrinter<'a> {
227− fn print_header(&mut self, handle: &mut dyn Write, file: InputFile) -> Result<()> {
237+ fn print_header(
238+ &mut self,
239+ handle: &mut dyn Write,
240+ file: InputFile,
241+ file_name: Option<&str>,
242+ ) -> Result<()> {
228243 if !self.config.output_components.header() {
229244 if Some(ContentType::BINARY) == self.content_type && !self.config.show_nonprintable {
230245 let input = match file {
231246 InputFile::Ordinary(filename) => format!(
232247 "file '{}'",
233− self.config.filename.unwrap_or(&filename.to_string_lossy())
248+ file_name.unwrap_or(&filename.to_string_lossy())
234249 ),
235− _ => self.config.filename.unwrap_or("STDIN").to_owned(),
250+ _ => file_name.unwrap_or("STDIN").to_owned(),
236251 };
237252
238253 writeln!(
@@ -269,17 +284,9 @@ impl<'a> Printer for InteractivePrinter<'a> {
269284 let (prefix, name) = match file {
270285 InputFile::Ordinary(filename) => (
271286 "File: ",
272− Cow::from(
273− self.config
274− .filename
275− .unwrap_or(&filename.to_string_lossy())
276− .to_owned(),
277− ),
278− ),
279− _ => (
280− "File: ",
281− Cow::from(self.config.filename.unwrap_or("STDIN").to_owned()),
287+ Cow::from(file_name.unwrap_or(&filename.to_string_lossy()).to_owned()),
282288 ),
289+ _ => ("File: ", Cow::from(file_name.unwrap_or("STDIN").to_owned())),
283290 };
284291
285292 let mode = match self.content_type {