Guest User

Untitled

a guest
Jan 22nd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #!/usr/bin/env
  2.  
  3. # NOTE, Untested code.
  4. #
  5. # Possibly one of the faster wasy to concatenate two files in ruby.
  6. # Another way might be to use the lower level IO#sysread, IO#syswrite methods
  7. # I think the main benefit in this case is the reusing of the String instance as
  8. # the buffer.
  9.  
  10. dest = ARGV.shift
  11. src = ARGV.shift
  12.  
  13. bufsize = File.stat( dest ).blksize || 8192
  14.  
  15. File.open( dest, "a" ) do |d|
  16. File.open( src, "r" ) do |r|
  17. buffer = String.new()
  18. while b = r.read( bufsize, buffer ) do
  19. w.write( b )
  20. end
  21. end
  22. end
Add Comment
Please, Sign In to add comment