///
/// Convert a file to have Unix line endings.
///
/// * `filename` - Filename to open and change line endings for.
/// * `feedback` - Display feedback when file already has Unix line endings or is binary.
Convert a file to have Unix line endings.
`filename` - Filename to open and change line endings for.
`feedback` - Display feedback when file already has Unix line endings or is binary.
Convert a file to have Unix line endings . ` filename ` - Filename to open and change line endings for . ` feedback ` - Display feedback when file already has Unix line endings or is binary .
pub fn convert(filename: &str, feedback: bool) -> bool {
        let mut input = File::open(filename).unwrap();
        let mut contents = String::new();
        let _ = input.read_to_string(&mut contents);
        let ascii = Dos2Unix::is_ascii(contents.clone());
        let dos_eol = Dos2Unix::is_dos_eol(contents.clone());
        let message = "dos2unix: File already has Unix line endings or is binary.";
        let mut success = false;
        if ascii && dos_eol {
            let converted = Dos2Unix::to_unix_line_endings(contents.clone());
            let mut w = File::create(filename).unwrap();
            let _ = w.write_all(converted.join("").as_bytes());
            success = true;
        } else if feedback {
            println!("{}", message);
        }
        success
    }
pub fn convert ( filename : & str , feedback : bool ) -> bool { let mut input = File :: open ( filename ) . unwrap ( ) ; let mut contents = String :: new ( ) ; let _ = input . read_to_string ( & mut contents ) ; let ascii = Dos2Unix :: is_ascii ( contents . clone ( ) ) ; let dos_eol = Dos2Unix :: is_dos_eol ( contents . clone ( ) ) ; let message = " " ; let mut success = false ; if ascii && dos_eol { let converted = Dos2Unix :: to_unix_line_endings ( contents . clone ( ) ) ; let mut w = File :: create ( filename ) . unwrap ( ) ; let _ = w . write_all ( converted . join ( " " ) . as_bytes ( ) ) ; success = true ; } else if feedback { println ! ( " " message ) ; } success }
Convert a file to have Unix line endings.
Convert a file to have Unix line endings .
filename
&str
feedback
bool