how to check netwroked file timestamp?
I have written a text editor which, before saving the file, tries to check if
the file has been edited "underneath" it by an external editor.
The code I originally wrote, failed reliably when the file being edited was on
a "network drive" (running on Windows, accessing a file on some server).
And I'm wondering if anybody knows how to do this "correctly".
I used a state variable that contained the last write time of the file. And I
updated this variable with
(defun file-save (...)
(with-open-file (...)
(write-string ...))
(setf last-saved (get-universal-time)))
It appears that this results in a race condition - the (get-universal-time) on
the local machine results in a time which is always earlier than the actual
write-date of the networked file (i.e. the with-open-file appears to be
asynchronous and returns before the server has actually closed the file and
written the time stamp).
I changed (get-universal-time) to (file-write-date ...) and it works "better",
but, I can see that this leaves a tiny hole in the timing during which an
external write could sneak in and defeat my logic.
Is there a "better" call that I should be making - or, do most text editors
simply ignore the tiny timing hole?
thanx
pt