Skip navigation.
 
mlRe: Checking file modification dates in NSDocument
FROM : Jordan Krushen
DATE : Fri Jul 28 20:40:42 2006

On 7/27/06, Sanford Selznick <<email_removed>> wrote:

>    Before my users save files they've opened I want to first detect if
> any other users (on the network or otherwise) have modified the file.
> I want to do this by checking the mod date on the file before the
> user saves, and then compare this date to the mod date when the file
> was opened.


>    I'm writing the file data with [NSData writeToFile:path atomically:YES].


Be sure to understand what the 'atomically' flag does.  It creates a
*second* file, and moves it to where the first one was.  You're not
modifying the pre-existent file in place.

> PS - I've read TN2037 and don't want to implement file locking.


Then you're aware that all of the other work you're doing is
ultimately for nothing, due to the inherent race condition between
when you check for changes and when you commit the new file?  If you
don't use locks, then this code will quite possibly still destroy data
under heavy use.  You say you don't want to use locks, but you're
writing code to ultimately do the same thing -- with the difference
being that locks will prevent corruption, while your code will not.

J.

Related mailsAuthorDate
mlChecking file modification dates in NSDocument Sanford Selznick Jul 28, 01:18
mlRe: Checking file modification dates in NSDocument Jordan Krushen Jul 28, 20:40
mlRe: Checking file modification dates in NSDocument Sanford Selznick Jul 28, 22:01
mlRe: Checking file modification dates in NSDocument Jordan Krushen Jul 28, 22:53
mlRe: Checking file modification dates in NSDocument Sanford Selznick Jul 28, 23:04
mlRe: Checking file modification dates in NSDocument Jordan Krushen Jul 28, 23:26