mirror of
https://github.com/tobi/disktree.git
synced 2026-11-29 08:00:52 +00:00
disktree-core builds and measures on Windows. `windows.rs` holds what the standard library does not give: a directory listing through GetFileInformationByHandleEx with FileIdExtdDirectoryInfo, which carries each entry's allocation and file id for a whole buffer of entries. Opening every file for those two numbers made a walk of a home directory of 1.3 million files seven times slower (65 s against 9 s); the listing costs what FindNextFileW costs. Where a file system does not implement it (a Samba share answers ERROR_INVALID_LEVEL), the walk falls back to std's listing, with lengths. - Disk usage is the NTFS allocation: whole clusters, less for a compressed or sparse file, nothing for data kept in the file record. - Hardlinks count once on NTFS, keyed by volume serial and file id. FAT ids are documented as not unique and ReFS ids need all 128 bits, so neither is used; there a hardlink counts once per name. - Junctions and mounted folders are links, as std already treats them, so the walk stays on one volume unless links are followed. The whole disk is the drive the profile is on. - Removal refuses Windows, Program Files, ProgramData and what Windows keeps at the top of its drive, comparing names without case. A mounted folder is a mount point. A link to a directory is removed with RemoveDirectoryW, which leaves its target alone. - Move to trash is the Recycle Bin, through the trash crate, which asks the shell to warn before destroying anything it cannot recycle. All unsafe code is in windows.rs, each block with the reason it is sound. On Unix the walk reads the same metadata through the same calls.