checking file busy/in use status

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
Martin Koob
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 239
Joined: Sun May 27, 2007 8:19 pm

checking file busy/in use status

Post by Martin Koob » Sat Apr 05, 2008 3:00 am

I am trying to figure out how to determine if a file has been opened by a revolution standalone so that another user running the standalone on a networked Mac won't be able to open it and edit it. The files I am using are xml files. I have tried to use the lsof file command using the terminal but it does not show the xml file if it is open. What is interesting is that my standalone app also opens a quicktime movie at the same time as the xml file. The unix lsof command does show the quicktime file is open. (I am checking this on the local Mac. Haven't tried this on a network yet.)

Is there some way you have to set a busy flag for the finder when you open an xml document with a revolution standalone? OR Is there a way to determine if a file is in use prior to opening it.


VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1236
Joined: Sat Apr 08, 2006 1:10 pm
Location: Zurich

Post by BvG » Sat Apr 05, 2008 11:47 am

Because every OS has it's own (or none at all) lock state for files in use, Rev doesn't have a build in way to do this.

Some people make their own, using an empty file, and if the "indicator" file exists, then the "productive" file is open from another application. Unfortunately, this is more complex then one might think, especially in network environment. What if the application who locked the file crashes, looses connection, or a user goes home without closing the app? So you'd need to always know if an app is using the file, and when it stopped using it.

One way to do this is to have a central server application which allows/disallows clients to use the files. This server then would disallow clients which have not been active for a specific amount of time.

Another way is to store information in a more complex "lock indicator" file, for example the last time the file was actually accessed. Then all clients would need to update this in intervals (for example every 5 minutes). A client might then "take over" the locked file, if there haven't been any updates since 11 minutes (or similar).

Obviously these approaches assumes that you have control over all applications that use your files.
Various teststacks and stuff:

Chat with other RunRev developers: #livecode

Post Reply

Return to “Mac OS”