Re: Exclusive File Access
Re: Exclusive File Access
- Subject: Re: Exclusive File Access
- From: Malte Tancred <email@hidden>
- Date: Thu, 21 Nov 2002 13:47:11 +0100
On thursday, nov 21, 2002, at 12:28 Europe/Stockholm, mw wrote:
Here's my idea. Let's say that Person A opens a file (that is all well
and
simple, right?), and Person B opens the same file at about the same
time
(doesn't really matter). Person A makes some changes. The program
checks
either the modification date of the file, or some other
"change-tracker"
(such as an MD5 hash, which I believe was suggested previously). It
sees
that the file hasn't changed, so it does a normal save (overwriting the
original file with the new information). Now, let's say that Person B
makes
some changes to a completely different part of the file. When he
saves, the
program performs the same check, and finds that there have been
modifications to the file between the time it was opened by Person B
and the
current save. So The program reads the whole file into memory. Now, we
have
2 copies of the file in RAM, the original one (modified by Person A,
though), and the one modified by Person B. So the program starts the
process
of comparing the elements of 2 file contents in RAM, and then writes
the
verified changes back to file.
What happens if Person C beats Person B to it, before Person B's
program is finished comparing the version saved by Person A with Person
B's own version?
Concurrent versioning is a difficult problem to solve. There are tools
dedicated to handle these situations. Use these tools and keep your own
programs simple.
Cheerio,
Malte
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.