Re: Atomic file check/opening?

From: Date: Wed, 05 Jul 2000 23:59:06 +0000
Subject: Re: Atomic file check/opening?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-5106@lists.php.net to get a copy of this message
You might find that a semaphore with a max_acquire value of 1 would be faster and less stressful to your disk I/O subsystems. I just wish that there was an optional timeout parameter for the sem_acquire function. Doug Kris Kelley was heard at 06:16 PM 7/5/00 -0500 to say: >Is there a function in PHP 4 (I'm using 4.0.1, specifically) that checks or >the existence of a file, then creates it if it doesn't exist, all in one >"atomic" process? In C under Unix, I would use this: > > fdes = open("path/to/file",O_WRONLY|O_CREAT|O_EXCL,0); > >I need this to "lock" a directory, so that only one process at a time can >move files into or out of the directory. I have checked the documentation >for fopen and flock, but they don't seem to have what I am looking for. > >Thanks for any help! > >---Kris Kelley >

« previous php.general (#5106) next »