How do you determine the optimal disk IO block size on Win32?
On Posix systems, the st_blksize member of the stat structure contains the optimal block size for IO for a given file. It looks like the Win32 implementations of stat (_stat & _stat64) do not support this field. What is the Win32 equivalent way of determining the optimal IO block size for a gi开发者_运维知识库ven file or filesystem?
I'm not sure if this will always return the optimal number, but the Win32 call GetDiskFreeSpace
returns, among other things, lpBytesPerSector
and lpSectorsPerCluster
; multiply those to get the bytes per cluster which is (perhaps) a reasonable value to use as a buffer size.
This call doesn't apply to files, but rather file systems, so you'd have to figure out what root the file lives on before using it.
精彩评论