From: Heesob Park Date: 2008-05-16T16:49:45+09:00 Subject: Re: Create an empty file of certain size Robert Klemme wrote: > 2008/5/16 Mark Dodwell : >>> fd.truncate( 2 ** 20 ) >> >> Thanks that's great, didn't know about that method! > > If it does not work on your platform, you can speed up your solution > by writing larger chunks: > > BUFFER = ("a" * 1024).freeze > File.open("tmp.txt", 'wb') { |f| 10.kilobytes.times { f.write BUFFER } } > Here is another way: size = 2**30 File.open("tmp.txt","wb"){|f|f.seek(size-1);f.write("\0")} Regards, Park Heesob -- Posted via http://www.ruby-forum.com/.