kenth has asked for the wisdom of the Perl Monks concerning the following question:
# Script create_big_file.pl # # Generates a file 10gb in size. Use -s to change the size. # use Getopt::Std; my $usage = <<EOT; Usage: $0 [-h] [-f file] [-s size] -h This help screen. -f file The file to create. -s size Size of the file to create in GB. Example: create_big_file.bat -s 26 -f 26gb.dat EOT warn($usage), exit(0) if !getopts('hf:s:',\%OPT) or $OPT{'h'}; $filesize = 10000000000; if ($OPT{'s'}) { $filesize = $OPT{'s'} * 1000000000 ; } $filename = "oat_bigfile_1.dat"; if ( $OPT{'f'}) { $filename = $OPT{'f'}; } $size = $filesize -1; print STDOUT "Creating $filename of $filesize bytes.\n"; open(BIGFILE, "+>", "$filename") || die ("Could not create $filename.\ +n"); binmode BIGFILE; die("Could not extend $filename to $filesize bytes.\n") unless seek BI +GFILE, $size, 0; print BIGFILE "\0"; seek BIGFILE, 0, 0; close BIGFILE;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Pre-extend a file on Windows
by BrowserUk (Patriarch) on Jul 13, 2007 at 20:03 UTC | |
by kenth (Initiate) on Jul 16, 2007 at 12:17 UTC | |
|
Re: Pre-extend a file on Windows
by jwkrahn (Abbot) on Jul 13, 2007 at 19:32 UTC | |
|
Re: Pre-extend a file on Windows
by toolic (Bishop) on Jul 13, 2007 at 19:39 UTC | |
|
Re: Pre-extend a file on Windows
by thezip (Vicar) on Jul 13, 2007 at 19:51 UTC | |
|
Re: Pre-extend a file on Windows
by andreas1234567 (Vicar) on Jul 13, 2007 at 20:03 UTC |