|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2012-04-21 20:23 UTC] michaelmotes at email dot com
[2012-06-26 14:49 UTC] ralph at ralphschindler dot com
[2012-06-26 23:44 UTC] kedomingo at gmail dot com
-Status: Open
+Status: Closed
[2012-06-26 23:44 UTC] kedomingo at gmail dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 17 09:00:01 2025 UTC |
Description: ------------ While I can create a file, write to it, close it, and delete it via unlink, I can't delete a file created by the buildFromDirectory function of PharData. I suspect that the file has been left open. Test script: --------------- <?php $file = uniqid().".txt"; /// Demo: Script can create and delete a file (if properly closed) normally if( !($f = fopen($file, 'w')) ) echo "Could not open $file <br />\n"; if( !fwrite($f, 'test') ) echo "Could not write to $file <br />\n"; if( !fclose($f) ) echo "Could not close $file <br />\n"; if( !unlink($file) ) echo "Could not delete $file <br />\n"; if( !is_dir( $dir = dirname(__FILE__) . '/phartest' ) ) { /// Create test directory for PharData mkdir( dirname(__FILE__) . '/phartest' ); for($i = 0; $i < 3; $i++) { $f = fopen($dir . "/file$i.txt", 'w'); fwrite($f, $i); fclose($f); }; } $file2 = uniqid().".zip"; /// Create test archive in the same directory as the demo file $phar = new PharData($file2); if( $phar->buildFromDirectory($dir) ) if(!unlink($file2)) /// Did phar close the file? Can we delete it? echo "Could not delete $file2!"; ?> Expected result: ---------------- I expect that the call to unlink($file2) will delete the newly created archive (with filename $file2) Actual result: -------------- Warning: unlink(<$file2>): Permission denied in C:\htdocs\phartest.php on line 17 Could not delete <$file2>!