Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #3817

Prevent unlink(...) warning

From Simon <bad@example.com>
Newsgroups comp.lang.php
Subject Prevent unlink(...) warning
Date 2011-11-17 17:04 +0200
Message-ID <9ikm3eFih4U1@mid.individual.net> (permalink)

Show all headers | View raw


Hi,

I am having some race condition issues on my server when trying to 
delete a file.

//
function my_unlink( $filename )
{
   //  remove the old file
   clearstatcache(TRUE, $filename);
   if (file_exists($filename))
   {
     @unlink($filename);
   }
   else
   {
     return true;
   }

   clearstatcache(TRUE, $filename);
   return (!file_exists($filename));  // check it was deleted.
}
//

In some cases I get

unlink(/home/xxx/public_html/temp/yyy.zz) [function.unlink]: No such 
file or directory

How can I prevent the warning?

Thanks

Simon

Back to comp.lang.php | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Prevent unlink(...) warning Simon <bad@example.com> - 2011-11-17 17:04 +0200
  Re: Prevent unlink(...) warning The Natural Philosopher <tnp@invalid.invalid> - 2011-11-17 15:18 +0000
    Re: Prevent unlink(...) warning Simon <bad@example.com> - 2011-11-17 19:21 +0200
      Re: Prevent unlink(...) warning The Natural Philosopher <tnp@invalid.invalid> - 2011-11-17 18:29 +0000
  Re: Prevent unlink(...) warning "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2011-11-17 18:42 +0100
  Re: Prevent unlink(...) warning Jerry Stuckle <jstucklex@attglobal.net> - 2011-11-17 13:54 -0500

csiph-web