windows version for Error out on save if file has changed since we opened it
diff --git a/goo/gfile.cc b/goo/gfile.cc
index f7a4a9b..8659440 100644
--- a/goo/gfile.cc
+++ b/goo/gfile.cc
@@ -24,7 +24,7 @@
// Copyright (C) 2013 Adam Reichold <adamreichold@myopera.com>
// Copyright (C) 2013, 2017 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2013 Peter Breitenlohner <peb@mppmu.mpg.de>
-// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
+// Copyright (C) 2013, 2017 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2017 Christoph Cullmann <cullmann@kde.org>
//
// To see a description of the changes please see the Changelog file that
@@ -599,6 +599,10 @@
#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 @@
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 6bbcb90..13dfa3a 100644
--- a/goo/gfile.h
+++ b/goo/gfile.h
@@ -23,6 +23,7 @@
// Copyright (C) 2014 Bogdan Cristea <cristeab@gmail.com>
// Copyright (C) 2014 Peter Breitenlohner <peb@mppmu.mpg.de>
// Copyright (C) 2017 Christoph Cullmann <cullmann@kde.org>
+// Copyright (C) 2017 Thomas Freitag <Thomas.Freitag@alfa.de>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
@@ -147,11 +148,12 @@
~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); }