Commit 3263fa44 authored by Thomas Freitag's avatar Thomas Freitag Committed by Albert Astals Cid

windows version for Error out on save if file has changed since we opened it

parent e4ee1392
......@@ -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 @@ 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 {
......
......@@ -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 @@ 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); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment