diff --git a/reactos/tools/rbuild/backend/mingw/mingw.cpp b/reactos/tools/rbuild/backend/mingw/mingw.cpp index 55fca0dbb60..916108bc10d 100644 --- a/reactos/tools/rbuild/backend/mingw/mingw.cpp +++ b/reactos/tools/rbuild/backend/mingw/mingw.cpp @@ -522,6 +522,9 @@ MingwBackend::GenerateXmlBuildFilesMacro() const ProjectNode.GetProjectFilename ().c_str () ); string xmlbuildFilenames; int numberOfExistingFiles = 0; + struct stat statbuf; + time_t SystemTime, lastWriteTime; + for ( size_t i = 0; i < ProjectNode.xmlbuildfiles.size (); i++ ) { XMLInclude& xmlbuildfile = *ProjectNode.xmlbuildfiles[i]; @@ -530,6 +533,28 @@ MingwBackend::GenerateXmlBuildFilesMacro() const numberOfExistingFiles++; if ( xmlbuildFilenames.length () > 0 ) xmlbuildFilenames += " "; + + FILE* f = fopen ( xmlbuildfile.topIncludeFilename.c_str (), "rb" ); + if ( !f ) + throw FileNotFoundException ( NormalizeFilename ( xmlbuildfile.topIncludeFilename ) ); + + if ( fstat ( fileno ( f ), &statbuf ) != 0 ) + { + fclose ( f ); + throw AccessDeniedException ( NormalizeFilename ( xmlbuildfile.topIncludeFilename ) ); + } + + lastWriteTime = statbuf.st_mtime; + SystemTime = time(NULL); + + if (SystemTime != -1) + { + if (difftime (lastWriteTime, SystemTime) > 0) + throw InvalidDateException ( NormalizeFilename ( xmlbuildfile.topIncludeFilename ) ); + } + + fclose ( f ); + xmlbuildFilenames += NormalizeFilename ( xmlbuildfile.topIncludeFilename ); if ( numberOfExistingFiles % 5 == 4 || i == ProjectNode.xmlbuildfiles.size () - 1 ) { diff --git a/reactos/tools/rbuild/exception.cpp b/reactos/tools/rbuild/exception.cpp index 90a1478dda3..a375f984620 100644 --- a/reactos/tools/rbuild/exception.cpp +++ b/reactos/tools/rbuild/exception.cpp @@ -64,6 +64,13 @@ InvalidOperationException::InvalidOperationException ( { } +InvalidDateException::InvalidDateException ( const string& filename) + : Exception ( "File '%s' has an invalid date.", + filename.c_str() ) +{ + Filename = filename; +} + InvalidOperationException::InvalidOperationException ( const char* filename, const int linenumber, diff --git a/reactos/tools/rbuild/exception.h b/reactos/tools/rbuild/exception.h index 82db9cb4051..3b1fbb5dda9 100644 --- a/reactos/tools/rbuild/exception.h +++ b/reactos/tools/rbuild/exception.h @@ -73,6 +73,12 @@ public: std::string Filename; }; +class InvalidDateException : public Exception +{ +public: + InvalidDateException ( const std::string& filename ); + std::string Filename; +}; class RequiredAttributeNotFoundException : public XMLInvalidBuildFileException {