Add a uniqueID field to the FileStatus structure for Paths. This will map
authorReid Spencer <rspencer@reidspencer.com>
Thu, 29 Mar 2007 17:00:31 +0000 (17:00 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Thu, 29 Mar 2007 17:00:31 +0000 (17:00 +0000)
to the inode number on Unix and something far less unique on Windows. The
windows case needs to be improved.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35461 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/System/Path.h
lib/System/Unix/Path.inc
lib/System/Win32/Path.inc

index 34373ae6a37363f04ff96e4cb156e029c9b921c4..578bb3cca087c9dd96ae1d96fe44728d16594af3 100644 (file)
@@ -40,17 +40,19 @@ namespace sys {
     uint32_t    mode;       ///< Mode of the file, if applicable
     uint32_t    user;       ///< User ID of owner, if applicable
     uint32_t    group;      ///< Group ID of owner, if applicable
+    uint64_t    uniqueID;   ///< A number to uniquely ID this file
     bool        isDir  : 1; ///< True if this is a directory.
     bool        isFile : 1; ///< True if this is a file.
 
     FileStatus() : fileSize(0), modTime(0,0), mode(0777), user(999),
-                   group(999), isDir(false) { }
+                   group(999), uniqueID(0), isDir(false), isFile(false) { }
     
     TimeValue getTimestamp() const { return modTime; }
     uint64_t getSize() const { return fileSize; }
     uint32_t getMode() const { return mode; }
     uint32_t getUser() const { return user; }
     uint32_t getGroup() const { return group; }
+    uint32_t getUniqueID() const { return uniqueID; }
   };
 
   /// This class provides an abstraction for the path to a file or directory
index b155213ec627edbeca10fb11f6c2c0b161009544..5557282964eded2cc28b3c9ee47e756b4e9c1962 100644 (file)
@@ -375,6 +375,7 @@ Path::getFileStatus(FileStatus &info, bool update, std::string *ErrStr) const {
     status->mode = buf.st_mode;
     status->user = buf.st_uid;
     status->group = buf.st_gid;
+    status->uniqueID = uint64_t(buf.st_ino);
     status->isDir  = S_ISDIR(buf.st_mode);
     status->isFile = S_ISREG(buf.st_mode);
   }
index 1f809ecfa56d8b7a2207ddf8af9e7bfe1fa3751f..f5edaa07edbd98b6a4757f2cdf5bb1bb6284249b 100644 (file)
@@ -319,6 +319,13 @@ Path::getFileStatus(FileStatus &info, bool update, std::string *ErrStr) const {
     status->user = 9999;    // Not applicable to Windows, so...
     status->group = 9999;   // Not applicable to Windows, so...
 
+    // 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.
+    status->uniqueID = 0;
+    for (unsigned i = 0; i < path.length(); ++i)
+      status->uniqueID += path[i];
+
     __int64 ft = *reinterpret_cast<__int64*>(&fi.ftLastWriteTime);
     status->modTime.fromWin32Time(ft);