Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env
- # NOTE, Untested code.
- #
- # Possibly one of the faster wasy to concatenate two files in ruby.
- # Another way might be to use the lower level IO#sysread, IO#syswrite methods
- # I think the main benefit in this case is the reusing of the String instance as
- # the buffer.
- dest = ARGV.shift
- src = ARGV.shift
- bufsize = File.stat( dest ).blksize || 8192
- File.open( dest, "a" ) do |d|
- File.open( src, "r" ) do |r|
- buffer = String.new()
- while b = r.read( bufsize, buffer ) do
- w.write( b )
- end
- end
- end
Add Comment
Please, Sign In to add comment