Reply to unlink, symlink and caching

Your name:

Reply:


Posted by jgmtfia Mr on 12/21/05 20:27

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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация