cvs: pear-core /PEAR2/Package Tar.php /PEAR2/Package/Tar Exception.php

From: Date: Fri, 29 Dec 2006 16:55:35 +0000
Subject: cvs: pear-core /PEAR2/Package Tar.php /PEAR2/Package/Tar Exception.php
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-core+get-5316@lists.php.net to get a copy of this message
cellog Fri Dec 29 16:55:35 2006 UTC Added files: /pear-core/PEAR2/Package/Tar Exception.php Modified files: /pear-core/PEAR2/Package Tar.php Log: fix removal of temporary files add missing PEAR2_Tar_Exception http://cvs.php.net/viewvc.cgi/pear-core/PEAR2/Package/Tar.php?r1=1.2&r2=1.3&diff_format=u Index: pear-core/PEAR2/Package/Tar.php diff -u pear-core/PEAR2/Package/Tar.php:1.2 pear-core/PEAR2/Package/Tar.php:1.3 --- pear-core/PEAR2/Package/Tar.php:1.2 Fri Dec 29 05:48:22 2006 +++ pear-core/PEAR2/Package/Tar.php Fri Dec 29 16:55:35 2006 @@ -30,19 +30,26 @@ } } + /** + * Sort files/directories for removal + * + * Files are always removed first, followed by directories in + * path order + * @param unknown_type $a + * @param unknown_type $b + * @return unknown + */ function sortstuff($a, $b) { + // files can be removed in any order + if (is_file($a) && is_file($b)) return 0; + if (is_dir($a) && is_file($b)) return 1; + if (is_dir($b) && is_file($a)) return -1; $countslasha = substr_count($a, DIRECTORY_SEPARATOR); $countslashb = substr_count($b, DIRECTORY_SEPARATOR); if ($countslasha > $countslashb) return -1; if ($countslashb > $countslasha) return 1; - $dira = dirname($a); - $dirb = dirname($b); - if ($dira == $dirb) { - return strnatcasecmp($a, $b); - } - if (strlen($dira) > strlen($dirb)) return -1; - if (strlen($dirb) > strlen($dira)) return 1; + // if not subdirectories, tehy can be removed in any order return 0; } @@ -54,15 +61,7 @@ if (is_file($fileOrDir)) { unlink($fileOrDir); } elseif (is_dir($fileOrDir)) { - if (!@rmdir($fileOrDir)) { - $dir = opendir($fileOrDir); - while (false !== ($entry = readdir($dir))) { - if ($entry == '.' || $entry == '..') { - continue; - } - unlink($fileOrDir . DIRECTORY_SEPARATOR . $entry); - } - } + rmdir($fileOrDir); } } } http://cvs.php.net/viewvc.cgi/pear-core/PEAR2/Package/Tar/Exception.php?view=markup&rev=1.1 Index: pear-core/PEAR2/Package/Tar/Exception.php +++ pear-core/PEAR2/Package/Tar/Exception.php <?php class PEAR2_Package_Tar_Exception extends PEAR2_Exception {}

« previous php.pear.core (#5316) next »