mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-19 04:32:19 +00:00
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
This commit is contained in:
parent
a1694e5784
commit
29c17db650
@ -33,6 +33,7 @@
|
|||||||
#include "llvm/ADT/Twine.h"
|
#include "llvm/ADT/Twine.h"
|
||||||
#include "llvm/Support/DataTypes.h"
|
#include "llvm/Support/DataTypes.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
|
#include "llvm/Support/TimeValue.h"
|
||||||
#include "llvm/Support/system_error.h"
|
#include "llvm/Support/system_error.h"
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
@ -151,6 +152,7 @@ class file_status
|
|||||||
#if defined(LLVM_ON_UNIX)
|
#if defined(LLVM_ON_UNIX)
|
||||||
dev_t fs_st_dev;
|
dev_t fs_st_dev;
|
||||||
ino_t fs_st_ino;
|
ino_t fs_st_ino;
|
||||||
|
time_t fs_st_mtime;
|
||||||
#elif defined (LLVM_ON_WIN32)
|
#elif defined (LLVM_ON_WIN32)
|
||||||
uint32_t LastWriteTimeHigh;
|
uint32_t LastWriteTimeHigh;
|
||||||
uint32_t LastWriteTimeLow;
|
uint32_t LastWriteTimeLow;
|
||||||
@ -177,6 +179,7 @@ public:
|
|||||||
// setters
|
// setters
|
||||||
void type(file_type v) { Type = v; }
|
void type(file_type v) { Type = v; }
|
||||||
void permissions(perms p) { Perms = p; }
|
void permissions(perms p) { Perms = p; }
|
||||||
|
TimeValue getLastModificationTime();
|
||||||
};
|
};
|
||||||
|
|
||||||
/// file_magic - An "enum class" enumeration of file types based on magic (the first
|
/// file_magic - An "enum class" enumeration of file types based on magic (the first
|
||||||
|
@ -110,6 +110,12 @@ namespace llvm {
|
|||||||
namespace sys {
|
namespace sys {
|
||||||
namespace fs {
|
namespace fs {
|
||||||
|
|
||||||
|
TimeValue file_status::getLastModificationTime() {
|
||||||
|
TimeValue Ret;
|
||||||
|
Ret.fromEpochTime(fs_st_mtime);
|
||||||
|
return Ret;
|
||||||
|
}
|
||||||
|
|
||||||
error_code current_path(SmallVectorImpl<char> &result) {
|
error_code current_path(SmallVectorImpl<char> &result) {
|
||||||
#ifdef MAXPATHLEN
|
#ifdef MAXPATHLEN
|
||||||
result.reserve(MAXPATHLEN);
|
result.reserve(MAXPATHLEN);
|
||||||
@ -401,6 +407,7 @@ error_code status(const Twine &path, file_status &result) {
|
|||||||
|
|
||||||
result.fs_st_dev = status.st_dev;
|
result.fs_st_dev = status.st_dev;
|
||||||
result.fs_st_ino = status.st_ino;
|
result.fs_st_ino = status.st_ino;
|
||||||
|
result.fs_st_mtime = status.st_mtime;
|
||||||
|
|
||||||
return error_code::success();
|
return error_code::success();
|
||||||
}
|
}
|
||||||
|
@ -128,6 +128,16 @@ namespace llvm {
|
|||||||
namespace sys {
|
namespace sys {
|
||||||
namespace fs {
|
namespace fs {
|
||||||
|
|
||||||
|
TimeValue file_status::getLastModificationTime() {
|
||||||
|
ULARGE_INTEGER UI;
|
||||||
|
UI.LowPart = LastWriteTimeLow;
|
||||||
|
UI.HighPart = LastWriteTimeHigh;
|
||||||
|
|
||||||
|
TimeValue Ret;
|
||||||
|
Ret.fromWin32Time(UI.QuadPart);
|
||||||
|
return Ret;
|
||||||
|
}
|
||||||
|
|
||||||
error_code current_path(SmallVectorImpl<char> &result) {
|
error_code current_path(SmallVectorImpl<char> &result) {
|
||||||
SmallVector<wchar_t, 128> cur_path;
|
SmallVector<wchar_t, 128> cur_path;
|
||||||
cur_path.reserve(128);
|
cur_path.reserve(128);
|
||||||
|
@ -583,15 +583,14 @@ doReplaceOrInsert(std::string* ErrMsg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (found != remaining.end()) {
|
if (found != remaining.end()) {
|
||||||
std::string Err;
|
sys::fs::file_status Status;
|
||||||
sys::PathWithStatus PwS(*found);
|
error_code EC = sys::fs::status(*found, Status);
|
||||||
const sys::FileStatus *si = PwS.getFileStatus(false, &Err);
|
if (EC)
|
||||||
if (!si)
|
|
||||||
return true;
|
return true;
|
||||||
if (!si->isDir) {
|
if (!sys::fs::is_directory(Status)) {
|
||||||
if (OnlyUpdate) {
|
if (OnlyUpdate) {
|
||||||
// Replace the item only if it is newer.
|
// Replace the item only if it is newer.
|
||||||
if (si->modTime > I->getModTime())
|
if (Status.getLastModificationTime() > I->getModTime())
|
||||||
if (I->replaceWith(*found, ErrMsg))
|
if (I->replaceWith(*found, ErrMsg))
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user