Created
November 4, 2018 06:16
-
-
Save apurvanandan1997/732492f5187047a5b95c967d49b951ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::fs; | |
use std::env; | |
fn main()-> std::io::Result<()> { | |
let args: Vec<String> = env::args().collect(); | |
if args[1]=="-r"{ | |
println!("Recurse"); | |
Ok(()) | |
} | |
else { | |
let meta = fs::symlink_metadata(args[1].clone()); | |
if meta.unwrap().file_type().is_symlink(){ | |
fs::soft_link(args[1].clone(), args[2].clone())?; | |
Ok(()) | |
} | |
else{ | |
fs::copy(args[1].clone(), args[2].clone())?; | |
Ok(()) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Code