>>> f = open('myfile.txt','w')
>>> f.seek(1024-1) # an example, pick any size
>>> f.write('\x00')
>>> f.close()
>>> os.stat('myfile.txt').st_size
1024L
>>>
/*
Creates an empty file, which can take all of the disk
space. Just specify the desired file size on the
command line.
*/
#include <windows.h>
#include <stdlib.h>
int main (int argc, char* ARGV[])
{
int size;
size = atoi(ARGV[1]);
const char* full = "fulldisk.dsk";
HANDLE hf = CreateFile(full,
GENERIC_WRITE,
0,
0,
CREATE_ALWAYS,
0,
0);
SetFilePointer(hf, size, 0, FILE_BEGIN);
SetEndOfFile(hf);
CloseHandle(hf);
return 0;
}
@echo off
:: Create file with 2 bytes
echo.>file-big.txt
:: Expand to 1 KB
for /L %%i in (1, 1, 9) do type file-big.txt>>file-big.txt
:: Expand to 1 MB
for /L %%i in (1, 1, 10) do type file-big.txt>>file-big.txt
:: Expand to 1 GB
for /L %%i in (1, 1, 10) do type file-big.txt>>file-big.txt
:: Expand to 4 GB
del file-4gb.txt
for /L %%i in (1, 1, 4) do type file-big.txt>>file-4gb.txt
del file-big.txt