Skip to content

Commit

Permalink
input file must exist
Browse files Browse the repository at this point in the history
  • Loading branch information
ajclark committed Jan 21, 2024
1 parent ef6f97b commit dac0b6e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use clap::{App, Arg};
use utils::split_and_copy_binary_file;
use std::env;
use std::process;
use std::path::Path;

fn main() {
let matches = App::new("Zap — Fast single file copy")
Expand Down Expand Up @@ -47,6 +48,15 @@ fn main() {
.default_value("22"))
.get_matches();

let input_file_path = matches.value_of("input_file").unwrap();

// Check if given input file exists
let path = Path::new(input_file_path);
if !path.is_file() {
eprintln!("Either the file {} does not exist, or it's a directory.", input_file_path);
process::exit(1);
}

let user_host_path = matches.value_of("user_host_path").unwrap();

// Split into user@host and remote_path
Expand Down Expand Up @@ -90,7 +100,6 @@ fn main() {
}
};

let input_file_path = matches.value_of("input_file").unwrap();
let num_streams: usize = matches.value_of("streams").unwrap().parse()
.expect("num_streams must be an integer");
let ssh_port: usize = matches.value_of("port").unwrap().parse()
Expand Down

0 comments on commit dac0b6e

Please sign in to comment.