Created
May 10, 2013 01:27
-
-
Save repomaa/5551828 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
begin | |
method = UI.ask_with_options(method_options, "l", "b", "s") | |
source = UI.ask("Copy from: ") | |
destination = UI.ask("Copy to: ") | |
case method | |
when "l" | |
CopyCtrl.copy_by_line source, destination | |
when "b" | |
begin | |
blocksize = UI.ask("Set blocksize (4096)", "Invalid blocksize.") do |input| | |
input.empty? || input.to_i.to_s == input && input.to_i > 0 | |
end | |
rescue EOFError | |
blocksize = 4096 | |
end | |
CopyCtrl.copy_by_block source, destination, blocksize.to_i | |
when "s" | |
CopyCtrl.copy_by_system source, destination | |
end | |
rescue CopyCtrl::OverwriteError | |
retry | |
rescue Errno::EACCES,Errno::ENOENT => e | |
puts e.message | |
retry | |
rescue Interrupt | |
#Ctrl-C, Ctrl-D or Enter | |
exit 0 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment