I’m looking for a way to make sure a file is only open once. it’s manly to prevent 2 user to open it at the same time and overwrite changes made by the other. this file is on a mac os X server.
i have to say that I’m very new to apple script. i can code php …
so far my best guess is change the permission on the file to only allow the owner to open it. then make a script that would change the owner to the user that want to open it, and change it back to root once the file is close.
with some if owner != root then cannot open file, else change owner to user and open …
i was wondering if any of you might have a better idea to make this.
I’m not on a network, but maybe you can use an alias file as a switcher. The user opens the file with the alias file. Then you switch the ‘original item’ of the alias file to some other file or application. Something like this:
set the_alias to alias “Macintosh HD:Users:kel:Desktop:Text”
set the_file to alias “Macintosh HD:Users:kel:Desktop:Text1.txt”
set user_notifier to alias “Macintosh HD:Users:kel:Desktop:Text2.txt”
– if file is in use
tell application “Finder”
set original item of the_alias to user_notifier
end tell
– if file not in use
tell application “Finder”
set original item of the_alias to the_file
end tell
The user_notifier could be anything that notifies the second user that the file is open.