diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Support/Unix/PathV2.inc | 12 | ||||
| -rw-r--r-- | lib/Support/Windows/PathV2.inc | 14 |
2 files changed, 26 insertions, 0 deletions
diff --git a/lib/Support/Unix/PathV2.inc b/lib/Support/Unix/PathV2.inc index c98c21d..9ea4f9e 100644 --- a/lib/Support/Unix/PathV2.inc +++ b/lib/Support/Unix/PathV2.inc @@ -350,6 +350,18 @@ error_code file_size(const Twine &path, uint64_t &result) { return error_code::success(); } +error_code GetUniqueID(const Twine Path, uint64_t &Result) { + SmallString<128> Storage; + StringRef P = Path.toNullTerminatedStringRef(Storage); + + struct stat Status; + if (::stat(P.begin(), &Status) != 0) + return error_code(errno, system_category()); + + Result = Status.st_ino; + return error_code::success(); +} + error_code status(const Twine &path, file_status &result) { SmallString<128> path_storage; StringRef p = path.toNullTerminatedStringRef(path_storage); diff --git a/lib/Support/Windows/PathV2.inc b/lib/Support/Windows/PathV2.inc index ea38389..3b2992d 100644 --- a/lib/Support/Windows/PathV2.inc +++ b/lib/Support/Windows/PathV2.inc @@ -413,6 +413,20 @@ error_code file_size(const Twine &path, uint64_t &result) { return error_code::success(); } +error_code GetUniqueID(const Twine Path, uint64_t &Result) { + // FIXME: this is only unique if the file is accessed by the same file path. + // How do we do this for C:\dir\file and ..\dir\file ? Unix has inode + // numbers, but the concept doesn't exist in Windows. + SmallString<128> Storage; + StringRef P = Path.toStringRef(Storage); + uint64_t UniqueID = 0; + for (StringRef::iterator I = P.begin(), E = P.end(); I != E; ++I) + UniqueID += *I; + Result = UniqueID; + + return error_code::success(); +} + static bool isReservedName(StringRef path) { // This list of reserved names comes from MSDN, at: // http://msdn.microsoft.com/en-us/library/aa365247%28v=vs.85%29.aspx |
