From 49c196c1056aaed97ff5cf43beff5c436d783b99 Mon Sep 17 00:00:00 2001 From: marha Date: Thu, 31 Jan 2013 10:29:48 +0100 Subject: mhmake: solved file date checking on 64-bit windows --- tools/mhmake/makefile | 16 +++++++++++----- tools/mhmake/src/build.cpp | 2 +- tools/mhmake/src/fileinfo.cpp | 17 +++++++++++++++++ tools/mhmake/src/fileinfo.h | 12 +++++++++--- tools/mhmake/src/mhmake.cpp | 7 +++++-- tools/mhmake/src/mhmakefileparser.cpp | 6 ++++++ tools/mhmake/src/util.h | 2 +- 7 files changed, 50 insertions(+), 12 deletions(-) (limited to 'tools') diff --git a/tools/mhmake/makefile b/tools/mhmake/makefile index b9aa0998b..f6a5a8ded 100644 --- a/tools/mhmake/makefile +++ b/tools/mhmake/makefile @@ -6,17 +6,23 @@ MHMAKESLNFILE=mhmakevc10.sln BUILDCMD=devenv.com $(MHMAKESLNFILE) /build endif +ifdef IS64 +SUBCONF=|x64 +SUBCONFDIR=64 +else +SUBCONF=|Win32 +endif .PHONY: all mhmake_dbg mhmake cleanthis -all: debug\mhmake_dbg.exe release\mhmake.exe +all: debug$(SUBCONFDIR)\mhmake_dbg.exe release$(SUBCONFDIR)\mhmake.exe DEPS=$(wildcard src\*) -debug\mhmake_dbg.exe: $(DEPS) - $(BUILDCMD) "Debug|Win32" +debug$(SUBCONFDIR)\mhmake_dbg.exe: $(DEPS) + $(BUILDCMD) "Debug$(SUBCONF)" -release\mhmake.exe: $(DEPS) - $(BUILDCMD) "Release|Win32" +release$(SUBCONFDIR)\mhmake.exe: $(DEPS) + $(BUILDCMD) "Release$(SUBCONF)" clean: cleanthis diff --git a/tools/mhmake/src/build.cpp b/tools/mhmake/src/build.cpp index ed9647d17..46e4f4916 100644 --- a/tools/mhmake/src/build.cpp +++ b/tools/mhmake/src/build.cpp @@ -1227,7 +1227,7 @@ mh_pid_t mhmakefileparser::ExecuteCommand(string Command, bool &IgnoreError, str break; } if (!Command.length()) - (mh_pid_t)0; + return (mh_pid_t)0; string InCommand=Command; if (g_Quiet) Echo=false; diff --git a/tools/mhmake/src/fileinfo.cpp b/tools/mhmake/src/fileinfo.cpp index 884d645b5..d9d16c1e3 100644 --- a/tools/mhmake/src/fileinfo.cpp +++ b/tools/mhmake/src/fileinfo.cpp @@ -96,6 +96,16 @@ string fileinfo::GetName() const /////////////////////////////////////////////////////////////////////////////// mh_time_t fileinfo::realGetDate() const { +#ifdef WIN32 + WIN32_FILE_ATTRIBUTE_DATA Attr; + BOOL Ret=GetFileAttributesEx(m_AbsFileName.c_str(), GetFileExInfoStandard, &Attr); + if (!Ret) + ((fileinfo*)this)->m_Date.SetNotExist(); + else if (Attr.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) + ((fileinfo*)this)->m_Date.SetDir(); + else + ((fileinfo*)this)->m_Date=*(mh_basetime_t*)&Attr.ftLastWriteTime; +#else struct stat Buf; if (-1==stat(m_AbsFileName.c_str(),&Buf)) ((fileinfo*)this)->m_Date.SetNotExist(); @@ -103,6 +113,7 @@ mh_time_t fileinfo::realGetDate() const ((fileinfo*)this)->m_Date.SetDir(); else ((fileinfo*)this)->m_Date=Buf.st_mtime; +#endif return m_Date; } @@ -141,7 +152,13 @@ bool fileinfo::IsDir() const /////////////////////////////////////////////////////////////////////////////// void fileinfo::SetDateToNow() { +#ifdef WIN32 + FILETIME ft; + GetSystemTimeAsFileTime(&ft); + m_Date=*(mh_basetime_t*)&ft; +#else m_Date=time(NULL); +#endif } /////////////////////////////////////////////////////////////////////////////// diff --git a/tools/mhmake/src/fileinfo.h b/tools/mhmake/src/fileinfo.h index b658ac677..f504a3cf3 100644 --- a/tools/mhmake/src/fileinfo.h +++ b/tools/mhmake/src/fileinfo.h @@ -67,6 +67,12 @@ inline string stringify(const T& x) return o.str(); } +#ifdef WIN32 +typedef unsigned _int64 mh_basetime_t; +#else +typedef unsigned long mh_basetime_t; +#endif + #define TIMESAFETY 3 class mh_time { @@ -76,13 +82,13 @@ class mh_time NOTEXISTTIME=1, DIRTIME =2+TIMESAFETY }; - unsigned long m_Time; + mh_basetime_t m_Time; bool operator < (const mh_time &Src); public: mh_time(){m_Time=DATENOTVALID;} - mh_time(time_t Time) : m_Time((unsigned long)Time) {} - mh_time(unsigned long Time) : m_Time(Time) {} + mh_time(time_t Time) : m_Time((mh_basetime_t)Time) {} + mh_time(mh_basetime_t Time) : m_Time(Time) {} mh_time(const mh_time &Time) : m_Time(Time.m_Time) {} void SetDir(void) diff --git a/tools/mhmake/src/mhmake.cpp b/tools/mhmake/src/mhmake.cpp index ef515b0b2..735453af6 100644 --- a/tools/mhmake/src/mhmake.cpp +++ b/tools/mhmake/src/mhmake.cpp @@ -75,8 +75,11 @@ int __CDECL main(int argc, char* argv[]) { mhmakefileparser::InitBuildTime(); - char PlatformEnv[]="PLATFORM="PLATFORM; - putenv(PlatformEnv); + if (!getenv("Platform")) + { + char PlatformEnv[]="PLATFORM="PLATFORM; + putenv(PlatformEnv); + } vector CmdLineArgs; for (int i=1; i