Re: check if file is already in use before fopen

From: Date: Thu, 04 Oct 2001 22:31:41 +0000
Subject: Re: check if file is already in use before fopen
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-69991@lists.php.net to get a copy of this message
Check out the "flock" fucntion At 16:20 4/10/2001 -0400, Jason Stechschulte wrote:
On Thu, Oct 04, 2001 at 11:10:56AM -0400, Matthew Luchak wrote: Is there a way to verify if a file is in use by another user before fopening it? As far as I know this is something you have to program in yourself. If you are only worried about your programs accessing the file, then it is a good idea to create a lock file. Before you access a file called mydata, check for a file called mydata.lock. If that exists, then the file is in use, so wait and check later. If it does not exist, create a file called mydata.lock, open mydata, do with it as you please, close mydata, and delete mydata.lock. You also have to be prepared to handle a situation where your program stops before removing the lock file. Usually with PHP, it is much easier to just use a database so all this file locking is dealt with by the database and not you. -- Jason Stechschulte jpstech@unoh.edu -- Sorry. My testing organization is either too small, or too large, depending on how you look at it. :-)
             -- Larry Wall in <1991Apr22.175438.8564@jpl-devvax.jpl.nasa.gov>
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net
------------------------- Brian White Step Two Designs Pty Ltd - SGML, XML & HTML Consultancy Phone: +612-93197901 Web: http://www.steptwo.com.au/ Email: bwhite@steptwo.com.au

« previous php.general (#69991) next »