-error_code getUniqueID(const Twine Path, uint64_t &Result) {
- file_status Status;
- if (error_code E = status(Path, Status))
- return E;
-
- // The file is uniquely identified by the volume serial number along
- // with the 64-bit file identifier.
- Result = (static_cast<uint64_t>(Status.FileIndexHigh) << 32ULL) |
- static_cast<uint64_t>(Status.FileIndexLow);
-
- // Because the serial number is 32-bits, but we've already used up all 64
- // bits for the file index, XOR the serial number into the high 32 bits of
- // the resulting value. We could potentially get collisons from this, but
- // the likelihood is low.
- Result ^= (static_cast<uint64_t>(Status.VolumeSerialNumber) << 32ULL);
-
- return error_code::success();
-}
-