You could fill out the last sector with zeros. If necessary for your
application you could then close the file, reopen the file without
FILE_FLAG_NO_BUFFERING and truncate the filler.
--
Scott McPhillips [VC++ MVP]
Without contradicting Scott's reply, I will point
out that there is an inherent conflict between what
you ask for when you specify FILE_FLAG_NO_BUFFERING,
your concept of arbitrary file size, and the usual
convention that file length is determined by how
much was written when the file is finally closed.
The hardware enforces a sector size and there is no
way to write fractional sectors with any drives in
my experience. So if you truly want to avoid any
buffering (except for the minimum necessary to pass
integer sector sized buffers to the I/O routines),
you will have to conform to that limitation.
Perhaps you should look at FlushFileBuffers(hFile)
and see if that will suit your purposes better
than impairing the filesystem buffering.
--
-Larry Brasfield
(address munged, s/sn/h/ to reply)