9 Ağustos 2007 Perşembe

Dummy File Generator

// This file generates a dummy file specified to your size.

#!c:/ruby/bin/ruby

require 'scanf'

print 'Enter file size (mb):'
a = scanf('%d')
thesize = a[0]
print 'You ordered a ' + thesize.to_s + ' MB file.'

# Generate the file
string = "abcdefghijklmnopqrstuvwxyz1234567890"
filesize = 0;

f = File.new(thesize.to_s + 'MB', 'w')

while filesize < thesize * 1e6
f.puts string
filesize += string.size
end

f.close


0 Comments: