diff --git a/goo/gfile.cc b/goo/gfile.cc index be75c5a6..3f05822e 100644 --- a/goo/gfile.cc +++ b/goo/gfile.cc @@ -599,6 +599,10 @@ Goffset GoffsetMax() { #ifdef _WIN32 +GooFile::GooFile(HANDLE handleA) : handle(handleA) { + GetFileTime(handleA, NULL, NULL, &modifiedTimeOnOpen); +} + int GooFile::read(char *buf, int n, Goffset offset) const { DWORD m; @@ -642,6 +646,14 @@ GooFile* GooFile::open(const wchar_t *fileName) { return handle == INVALID_HANDLE_VALUE ? NULL : new GooFile(handle); } +bool GooFile::modificationTimeChangedSinceOpen() const +{ + struct _FILETIME lastModified; + GetFileTime(handle, NULL, NULL, &lastModified); + + return modifiedTimeOnOpen.dwHighDateTime != lastModified.dwHighDateTime || modifiedTimeOnOpen.dwLowDateTime != lastModified.dwLowDateTime; +} + #else int GooFile::read(char *buf, int n, Goffset offset) const { diff --git a/goo/gfile.h b/goo/gfile.h index 233c4829..f9cc2609 100644 --- a/goo/gfile.h +++ b/goo/gfile.h @@ -147,11 +147,12 @@ public: ~GooFile() { CloseHandle(handle); } // Asuming than on windows you can't change files that are already open - bool modificationTimeChangedSinceOpen() const { return false; }; + bool modificationTimeChangedSinceOpen() const; private: - GooFile(HANDLE handleA): handle(handleA) {} + GooFile(HANDLE handleA); HANDLE handle; + struct _FILETIME modifiedTimeOnOpen; #else ~GooFile() { close(fd); }