llvm.org GIT mirror llvm / 29c17db
Add support for getting the last modification time from a file_status. Use that in llvm-ar.cpp to replace a use of sys::PathWithStatus. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184450 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 7 years ago
4 changed file(s) with 25 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
3232 #include "llvm/ADT/Twine.h"
3333 #include "llvm/Support/DataTypes.h"
3434 #include "llvm/Support/ErrorHandling.h"
35 #include "llvm/Support/TimeValue.h"
3536 #include "llvm/Support/system_error.h"
3637 #include
3738 #include
150151 #if defined(LLVM_ON_UNIX)
151152 dev_t fs_st_dev;
152153 ino_t fs_st_ino;
154 time_t fs_st_mtime;
153155 #elif defined (LLVM_ON_WIN32)
154156 uint32_t LastWriteTimeHigh;
155157 uint32_t LastWriteTimeLow;
176178 // setters
177179 void type(file_type v) { Type = v; }
178180 void permissions(perms p) { Perms = p; }
181 TimeValue getLastModificationTime();
179182 };
180183
181184 /// file_magic - An "enum class" enumeration of file types based on magic (the first
108108 namespace llvm {
109109 namespace sys {
110110 namespace fs {
111
112 TimeValue file_status::getLastModificationTime() {
113 TimeValue Ret;
114 Ret.fromEpochTime(fs_st_mtime);
115 return Ret;
116 }
111117
112118 error_code current_path(SmallVectorImpl &result) {
113119 #ifdef MAXPATHLEN
400406
401407 result.fs_st_dev = status.st_dev;
402408 result.fs_st_ino = status.st_ino;
409 result.fs_st_mtime = status.st_mtime;
403410
404411 return error_code::success();
405412 }
126126 namespace llvm {
127127 namespace sys {
128128 namespace fs {
129
130 TimeValue file_status::getLastModificationTime() {
131 ULARGE_INTEGER UI;
132 UI.LowPart = LastWriteTimeLow;
133 UI.HighPart = LastWriteTimeHigh;
134
135 TimeValue Ret;
136 Ret.fromWin32Time(UI.QuadPart);
137 return Ret;
138 }
129139
130140 error_code current_path(SmallVectorImpl &result) {
131141 SmallVector cur_path;
582582 }
583583
584584 if (found != remaining.end()) {
585 std::string Err;
586 sys::PathWithStatus PwS(*found);
587 const sys::FileStatus *si = PwS.getFileStatus(false, &Err);
588 if (!si)
585 sys::fs::file_status Status;
586 error_code EC = sys::fs::status(*found, Status);
587 if (EC)
589588 return true;
590 if (!si->isDir) {
589 if (!sys::fs::is_directory(Status)) {
591590 if (OnlyUpdate) {
592591 // Replace the item only if it is newer.
593 if (si->modTime > I->getModTime())
592 if (Status.getLastModificationTime() > I->getModTime())
594593 if (I->replaceWith(*found, ErrMsg))
595594 return true;
596595 } else {