16 May 00:24
Re: Create an empty file of certain size
From: ara.t.howard <ara.t.howard <at> gmail.com>
Subject: Re: Create an empty file of certain size
Newsgroups: gmane.comp.lang.ruby.general
Date: 2008-05-15 22:24:45 GMT
Subject: Re: Create an empty file of certain size
Newsgroups: gmane.comp.lang.ruby.general
Date: 2008-05-15 22:24:45 GMT
On May 15, 2008, at 4:09 PM, Mark Dodwell wrote:
> Hi,
>
> I need to create an empty (or at least garbage) file of a certain
> size.
> I'm doing it the way below, but it is rather slow -- any ideas on a
> quicker way?
>
> File.open("tmp.txt", 'w') { |f| 10.megabytes.times { f.write "a" } }
>
> Thanks!
>
> ~ Mark
fd.truncate( 2 ** 20 )
a @ http://codeforpeople.com/
--
we can deny everything, except that we have the possibility of being
better. simply reflect on that.
h.h. the 14th dalai lama
RSS Feed