@@ -1,7 +1,7 @@
11use std::convert::TryFrom;
2−use std::ffi::{OsStr, OsString};
32use std::fs::File;
43use std::io::{self, BufRead, BufReader, Read};
4+use std::path::{Path, PathBuf};
55
66use clircle::{Clircle, Identifier};
77use content_inspector::{self, ContentType};
@@ -69,7 +69,7 @@ impl InputDescription {
6969}
7070
7171pub(crate) enum InputKind<'a> {
72− OrdinaryFile(OsString),
72+ OrdinaryFile(PathBuf),
7373 StdIn,
7474 CustomReader(Box<dyn Read + 'a>),
7575}
@@ -86,7 +86,7 @@ impl<'a> InputKind<'a> {
8686
8787#[derive(Clone, Default)]
8888pub(crate) struct InputMetadata {
89− pub(crate) user_provided_name: Option<OsString>,
89+ pub(crate) user_provided_name: Option<PathBuf>,
9090}
9191
9292pub struct Input<'a> {
@@ -96,7 +96,7 @@ pub struct Input<'a> {
9696}
9797
9898pub(crate) enum OpenedInputKind {
99− OrdinaryFile(OsString),
99+ OrdinaryFile(PathBuf),
100100 StdIn,
101101 CustomReader,
102102}
@@ -109,8 +109,11 @@ pub(crate) struct OpenedInput<'a> {
109109}
110110
111111impl<'a> Input<'a> {
112− pub fn ordinary_file(path: &OsStr) -> Self {
113− let kind = InputKind::OrdinaryFile(path.to_os_string());
112+ pub fn ordinary_file(path: impl AsRef<Path>) -> Self {
113+ Self::_ordinary_file(path.as_ref())
114+ }
115+ fn _ordinary_file(path: &Path) -> Self {
116+ let kind = InputKind::OrdinaryFile(path.to_path_buf());
114117 Input {
115118 description: kind.description(),
116119 metadata: InputMetadata::default(),
@@ -140,7 +143,10 @@ impl<'a> Input<'a> {
140143 matches!(self.kind, InputKind::StdIn)
141144 }
142145
143− pub fn with_name(mut self, provided_name: Option<&OsStr>) -> Self {
146+ pub fn with_name(mut self, provided_name: Option<impl AsRef<Path>>) -> Self {
147+ self._with_name(provided_name.as_ref().map(|it| it.as_ref()))
148+ }
149+ pub fn _with_name(mut self, provided_name: Option<&Path>) -> Self {
144150 if let Some(name) = provided_name {
145151 self.description.name = name.to_string_lossy().to_string()
146152 }