making ntfs do faster deletes

Jay Norwood jayn at prismnet.com
Mon Apr 16 08:55:40 PDT 2012


On Monday, 16 April 2012 at 09:16:09 UTC, Kagamin wrote:
> Do you use FILE_FLAG_SEQUENTIAL_SCAN too?

The std.file.write does use FILE_FLAG_SEQUENTIAL_SCAN
void write(in char[] name, const void[] buffer)

my experimental code to create the empty file also uses it, but 
it doesn't write any buffers, just seeks to a position and calls 
SetEndOfFile.

void createEmptyFile(in char[] name, ulong length)
{
     version(Windows)
     {
         alias TypeTuple!(GENERIC_WRITE, 0, null, CREATE_ALWAYS,
						 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,
						 HANDLE.init)
             defaults;
         auto h = useWfuncs
             ? CreateFileW(std.utf.toUTF16z(name), defaults)
             : CreateFileA(toMBSz(name), defaults);

         cenforce(h != INVALID_HANDLE_VALUE, name);
         scope(exit) cenforce(CloseHandle(h), name);

		 SetFilePointerEx (h,  *cast(long *) &length,null, 0);
		 SetEndOfFile(h);
     }
     //else version(Posix)  not implemented
     //    return writeImpl(name, buffer, O_CREAT | O_WRONLY | 
O_TRUNC);
}

I tried a quick test of writing without the buffering, to see if 
that would provide results similar to the createEmptyFile() 
experiment. Unfortunately the return buffers from the uncompress  
call (I'm experimenting with unzip) are not compatible with 
unbuffered writing requirements, so the uncompressed data would 
need to be realigned and/or resized  ... not clear at the moment.


More information about the Digitalmars-d-learn mailing list