Re: File/Passwd

From: Date: Wed, 16 Jul 2003 19:36:11 +0000
Subject: Re: File/Passwd
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-18308@lists.php.net to get a copy of this message
it seems the problem is that windows does not let you rename a file while it is open, this is easily fixable, by first copying the file and then unlinking it. I will commit this patch if nobody objects in 10s function close() { if($this->locked) { foreach($this->users as $user => $pass) { if($this->cvs[$user]) { fputs($this->fplock, "$user:$pass:" . $this->cvs[$user] . "\n"); } else { fputs($this->fplock, "$user:$pass\n"); } } - rename($this->lockfile, $this->filename); + copy($this->lockfile, $this->filename); flock($this->fplock, LOCK_UN); $this->locked = false; fclose($this->fplock); + unlink($this->lockfile); } } // end func close() Yavor ----- Original Message ----- From: "Yavor Shahpasov" <yavo@siava.org> To: <pear-dev@lists.php.net> Sent: Wednesday, July 16, 2003 3:08 AM Subject: [PEAR-DEV] File/Passwd File/Passwd has a bug on windows on line 214 rename($this->lockfile, $this->filename); throws <br /> <b>Warning</b>: rename(./passwd.lock,users): Permission denied in <b>C:\php\pear\File\Passwd.php</b> on line <b>214</b><br /> i suggest using copy instead and possibly deleting the file, with destructors copy($this->lockfile, $this->filename); My target system is WinXP with PHP5 beta1, but I have seen this bug way back, so it would be good if it got fixed. Yavor

« previous php.pear.dev (#18308) next »