llvm.org GIT mirror llvm / 4031bef
Add a uniqueID field to the FileStatus structure for Paths. This will map 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 Reid Spencer 13 years ago
3 changed file(s) with 11 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
3939 uint32_t mode; ///< Mode of the file, if applicable
4040 uint32_t user; ///< User ID of owner, if applicable
4141 uint32_t group; ///< Group ID of owner, if applicable
42 uint64_t uniqueID; ///< A number to uniquely ID this file
4243 bool isDir : 1; ///< True if this is a directory.
4344 bool isFile : 1; ///< True if this is a file.
4445
4546 FileStatus() : fileSize(0), modTime(0,0), mode(0777), user(999),
46 group(999), isDir(false) { }
47 group(999), uniqueID(0), isDir(false), isFile(false) { }
4748
4849 TimeValue getTimestamp() const { return modTime; }
4950 uint64_t getSize() const { return fileSize; }
5051 uint32_t getMode() const { return mode; }
5152 uint32_t getUser() const { return user; }
5253 uint32_t getGroup() const { return group; }
54 uint32_t getUniqueID() const { return uniqueID; }
5355 };
5456
5557 /// This class provides an abstraction for the path to a file or directory
374374 status->mode = buf.st_mode;
375375 status->user = buf.st_uid;
376376 status->group = buf.st_gid;
377 status->uniqueID = uint64_t(buf.st_ino);
377378 status->isDir = S_ISDIR(buf.st_mode);
378379 status->isFile = S_ISREG(buf.st_mode);
379380 }
318318 status->user = 9999; // Not applicable to Windows, so...
319319 status->group = 9999; // Not applicable to Windows, so...
320320
321 // FIXME: this is only unique if the file is accessed by the same file path.
322 // How do we do this for C:\dir\file and ..\dir\file ? Unix has inode
323 // numbers, but the concept doesn't exist in Windows.
324 status->uniqueID = 0;
325 for (unsigned i = 0; i < path.length(); ++i)
326 status->uniqueID += path[i];
327
321328 __int64 ft = *reinterpret_cast<__int64*>(&fi.ftLastWriteTime);
322329 status->modTime.fromWin32Time(ft);
323330