Re: Questions on stream

From: Date: Fri, 05 Aug 2005 21:01:53 +0000
Subject: Re: Questions on stream
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-17554@lists.php.net to get a copy of this message
On Fri, 05 Aug 2005 16:48:21 -0400 Rob Richards <rrichards@ctindustries.net> wrote: > I was wondering if the following are bugs or expected behavior/wont change. > > Take the following code: > <?php > $handle = fopen("file.txt", "w"); > fwrite($handle, "SOME DATA"); > unlink("file.txt"); > if (fwrite($handle, "SOMEMORE") === FALSE) { > print "CANNOT WRITE"; > } else { > print "Wrote Data"; > } > fclose($handle); > ?> > > Under linux the file is deleted and the result is Wrote Data (even > though the last fwrite didnt do anything). That's because on Linux data gets phisically deleted only when number of hardlinks to it and number of open descriptors becomes 0. It's perfectly fine to open & delete file and continue writing to/reading from it. That's, btw, one of the well known methods used do get a temporary FD. > Under windows, the unlink() call results in a permissions denied error. Yup =) Also on Windows you can't open a file already opened by someone. > Shouldn't linux not allow the file to be deleted with an open stream as > well? No, why? -- Wbr, Antony Dovgal

« previous php.internals (#17554) next »