[llvm] [Support] Add path-based setLastAccessAndModificationTime overload (PR #199256)

Steven Wu via llvm-commits llvm-commits at lists.llvm.org
Fri May 22 12:53:10 PDT 2026


================
@@ -860,6 +860,22 @@ std::error_code setLastAccessAndModificationTime(int FD, TimePoint<> AccessTime,
 #endif
 }
 
+std::error_code setLastAccessAndModificationTime(const Twine &Path,
+                                                 TimePoint<> AccessTime,
+                                                 TimePoint<> ModificationTime) {
+  SmallString<128> PathStorage;
+  StringRef P = Path.toNullTerminatedStringRef(PathStorage);
+  // O_RDONLY opens directories on POSIX; futimens/futimes accept a directory
+  // file descriptor, so this works for both files and directories.
+  int FD = ::open(P.begin(), O_RDONLY);
----------------
cachemeifyoucan wrote:

Agree. And does the implementation needs to be platform specific? It should just be a convenience method that does openFile and setLastAccessAndModificationTime with fd?

https://github.com/llvm/llvm-project/pull/199256


More information about the llvm-commits mailing list