unlink, symlink and caching

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have a directory with the files:
	/config/A
	/config/B
and
	/config/C is a symlink to /config/A.

Via php I unlink /config/C:

	$FILE = '/config/C';
	while(file_exists($FILE)){
		unlink($FILE);
		clearstatcache();
	}

When run, the first time through the loop $FILE is removed from disk
as it should.

The loop then continues forever with file_exists() returning true, but
unlink() returns false with the error message "Warning:
unlink(/config1/C) [function.unlink]: No such file or directory in
/www/script.php on line 10"

If I do this:
	$FILE = '/config/C';
	unlink($FILE);
	cleanstatcache();
	symlink('/config/B', '/config/C');

I get the error message:
	Warning: symlink() [function.symlink]: File exists in /www/script.php
on line 11

However the link had been deleted.

The symlink /config/C is read via file_get_contents() before the
unlink and relink is performed.

I have also done the following:
	$FILE = '/config/C';
	unlink($FILE);
	`ln -s /config/B /config/C`

Which works as expected, the old link is replaced with the new link,
however any attempt to open and read from the new link returns the
contents of the old file.

How would I be able to get the expected behavior from PHP.  I expect
that the problem has something to do with the symlinks being used.

Any assistance is appreciated.


PHP Version: 5.1.0
Server API: Apache 2.0 Handler
PHP API: 20041225
PHP Extension: 20050922
Zend Extension: 220051025
Apache Version: Apache/2.0.52 (Unix) PHP/5.1.0
Apache API Version: 20020903

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux