-
September 13th, 2004, 11:04 PM
#1
help: howto prealloc a large file in disk?
Hi, everyone
I want to process a large image(maybe 1G), and write the processed result into an output file, but the procession is not a sequential one, so i maybe start to write from the EOF. My question is how to pre-allocate the required space in disk so i can write anywhere in the file when needed. I have tried using WriteFile API but it is too slow, it cost 55 milliseconds to wirte a 1G file , does anyone has better solutions?
When i use bittorrent, I notice that its pre-allocation is very fast, perhaps less than 1s.
Any comments will be appreciated
Thanks for helping!
Last edited by reviver; September 13th, 2004 at 11:07 PM.
-
September 14th, 2004, 02:35 AM
#2
Re: help: howto prealloc a large file in disk?
Try following sequence:
Code:
SetFilePointer(hFile, 1024*1024*1024, NULL, FILE_BEGIN);
SetEndOfFile(hFile);
SetFilePointer(hFile, 0, NULL, FILE_BEGIN);
I don't checked this, but I think that it should work.
With best wishes, Alexander Hritonenkov
-
September 14th, 2004, 04:00 AM
#3
Re: help: howto prealloc a large file in disk?
Thanks! it works.
I thought SetFilePointer can only move pointer in the actual range before.
Thanks again!
Time is a great teacher, but unfortunately it kills all its pupils.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|