PDA

View Full Version : Prepare FAKE files on disk [Python]



baskar007
January 2nd, 2010, 07:38 PM
Any one know how to create files with fake size on disk using python or whatever?
for example, in windows some downloader applications will create fake size files before they download full file.

if you not undestand:
when i download a 300mb movie file, the downloader application will create a 300mb size file on my HDD before it download fully.



sorry for my bad english, if you don't understand please tell me.

ssam
January 2nd, 2010, 07:46 PM
you can seek to where you want the file to end and write something.


f = open("foo", "w")
f.seek(300*1024*1024)
f.write("\0")
f.seek(0)
...
f.close()

baskar007
January 3rd, 2010, 04:45 AM
you can seek to where you want the file to end and write something.


f = open("foo", "w")
f.seek(300*1024*1024)
f.write("\0")
f.seek(0)
...
f.close()

It's awesome, thankyou.
But i have small doupt, we writing some data at the end of the file ("\0") this may corrupt our file data?

OgreProgrammer
January 3rd, 2010, 10:33 AM
It's awesome, thankyou.
But i have small doupt, we writing some data at the end of the file ("\0") this may corrupt our file data?

Just make it a few bytes shorter than the real file if you are concerned about that.

Can+~
January 3rd, 2010, 05:49 PM
It's awesome, thankyou.
But i have small doupt, we writing some data at the end of the file ("\0") this may corrupt our file data?

If you make the fake file of the exact same size as the original one, then it would, sooner or later, be stepped over by the real file, so I would say that you're safe.