>>>>The only reliable way to do it across all Win32 platform and file systems is to write get the amount of free space, write a small temporary file, and get the amount of free space afterwards.
>>>
>>>I disagree: this is not reliable. Another user or process may increase or decrease the free disk space in the meantime. Unless I create a thousand small temp files, and round to the nearest power of 2...
>>>
>>Disclaimer: I consider George Tasker to be technically reliable, and a reasonably good friend even though we've never met face to face, so I'm not completely unbiased.
>
>I agree; I have seen many of George's comments. The last thing I want to do is to insult him, and I hope my disagreement isn't taken as such.
>
>>Let me suggest you trust George; his recommendation of the API is spot on, and his recommendation on writing a small file and checking it's actual disk space consumption is dead on, too; with NTFS, or FAT systems with DriveSpace installed, you have the issues of sub-cluster file space allocation and automatic compression. In RAID arrays, the unit of allocation is most likely a multiple of the base space allocation unit (min NTFS partition cluster size) * (number of RAID spindles - 1) is common if NTFS compression is not used, and OBTW, compression and sub-cluster allocation is controlled at the file or folder level so the rules aren't consistent. The API call will return the correct base space allocation unit of the logical volume.
>
>Well, I had forgotten about some of these details. Especially, I was aware of "variable cluster size" in the case of DriveSpace and similar, but I didn't work with it for a long time. In this case, the basic "cluster size" can be taken as 512 bytes, I believe, because the "variable cluster size" is a multiple of this.
>
No; NTFS can perform subsector allocation on NTFS-compressed folders. Files can be of an exact length plus a small amount of descriptor overhead in the NTFS directory index.
>The real problem (for calculations) is data compression - summing file sizes can give you a maximum size, but the real space used will usually be less.
>
>With RAID, I think you were referring to RAID level 5, right?
The same rules apply to RAID 3, 4 and 5; RAID 0, which is soft striping without parity, does not reduce spindle count by 1.
>
>>
>>Maybe familiarizing yourself with Windows internals would be a worthwhile thing to work towards.
>
>I think I know most of the concepts you explained, but I was mainly considering a "standard" disk - one without compression. However, if it isn't too much trouble, can you briefly explain how "sub-cluster allocation" works in NTFS? Would several small files share a cluster? I had this suspition a while ago, when looking at the actual disk space used, as reported by Windows NT.
>
Yes; get your hands on the WinNT or Win2K Resource Kit, and they have discussions of NTFS compression, which includes sub-cluster allocation in compressed folders. There's also a considerably more detailed description in a book on the NTFS File System by O'Reilly and Associates, and a similar one on FAT/FAT32 and the IFS concepts introduced in Win95 OSR2/Win98/WinME, and added into Win2K and WinXP.
>Hilmar.