/****************************************************************************** * This program simply copies a file to the console line by line. * * Copyright © 2020 Richard Lesh. All rights reserved. *****************************************************************************/ mod utils; use std::error; use std::sync::Arc; fn readTextFile(filespec:&str) -> Result<(), Arc> { utf8mode(ifh); let mut line:&str = ""; while getline(line,ifh) { println!("{}", line); } close(ifh); } fn main() { if args.len() != 2 { println!("Syntax: {} {{filename}}", utils::program_name().expect("program name should not be empty!")); exit(1); } let mut filespec:String = args[1]; match (|| -> Result<(), Arc>{ readTextFile(&filespec)?; return Ok(()); })() { Ok(()) => {}, Err(ex) => { if let Some(ex) = utils::isCustomErrorType(ex.clone(), io::Error("".to_string())){ println!("Error: {}", format!("{}", ex)); } } }; }