@@ -34,7 +34,12 @@ use crate::terminal::{as_terminal_escaped, to_ansi_color};
3434use crate::wrap::OutputWrap;
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,14 +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.style_components.header() {
229244 if Some(ContentType::BINARY) == self.content_type && !self.config.show_nonprintable {
230245 let input = match file {
231− InputFile::Ordinary(filename) => {
232− format!("file '{}'", filename.to_string_lossy())
233− }
234− _ => "STDIN".into(),
246+ InputFile::Ordinary(filename) => format!(
247+ "file '{}'",
248+ file_name.unwrap_or(&filename.to_string_lossy())
249+ ),
250+ _ => file_name.unwrap_or("STDIN").to_owned(),
235251 };
236252
237253 writeln!(
@@ -266,8 +282,11 @@ impl<'a> Printer for InteractivePrinter<'a> {
266282 }
267283
268284 let (prefix, name) = match file {
269− InputFile::Ordinary(filename) => ("File: ", filename.to_string_lossy()),
270− _ => ("", Cow::from("STDIN")),
285+ InputFile::Ordinary(filename) => (
286+ "File: ",
287+ Cow::from(file_name.unwrap_or(&filename.to_string_lossy()).to_owned()),
288+ ),
289+ _ => ("File: ", Cow::from(file_name.unwrap_or("STDIN").to_owned())),
271290 };
272291
273292 let mode = match self.content_type {