/****************************************************************************** * This program simply copies a file to the console character by * character like the Unix 'cat' program. * * 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 c:i32 = 0; while getcodepoint(c,ifh) { putcodepoint(c); } 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)); } } }; }