From c3da36c800ddac04b4e3bf7b80b98962b4bf6a9b Mon Sep 17 00:00:00 2001 From: Michael Larabel Date: Mon, 29 Dec 2008 12:11:49 -0500 Subject: pts-core: Rewrite pts_remove() function --- CHANGE-LOG | 1 + pts-core/functions/pts-functions_shell.php | 39 ++++++++++++++---------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/CHANGE-LOG b/CHANGE-LOG index f4ce9d4..4732a24 100644 --- a/CHANGE-LOG +++ b/CHANGE-LOG @@ -13,6 +13,7 @@ Phoronix Test Suite (Git) - pts-core: Archive installation output of tests in the test's directory in file install.log - pts-core: Add install-all-dependencies option to install all available external dependencies for that distribution - pts-core: When installing or running a test, only print to standard output if under 10KB +- pts-core: Rewrite pts_remove() function - pts: Add UXA acceleration check to GtkPerf test note reporting - pts: Add 2d-test base profile that reports 2D acceleration mode using Cascading Test Profiles - pts: Add build-mysql test profile for timed build of MySQL 5.1 diff --git a/pts-core/functions/pts-functions_shell.php b/pts-core/functions/pts-functions_shell.php index ae54a28..7c4c715 100644 --- a/pts-core/functions/pts-functions_shell.php +++ b/pts-core/functions/pts-functions_shell.php @@ -77,37 +77,34 @@ function pts_download($download, $to) } function pts_remove($object, $ignore_files = null) { - if(!file_exists($object)) + if(is_dir($object) && substr($object, -1) != "/") { - return false; + $object .= "/"; } - if(is_file($object)) + foreach(glob($object . "*") as $to_remove) { - if(is_array($ignore_files) && in_array(basename($object), $ignore_files)) + if(is_file($to_remove)) { - return true; + if(is_array($ignore_files) && in_array(basename($to_remove), $ignore_files)) + { + continue; // Don't remove the file + } + else + { + @unlink($to_remove); + } } - else + else if(is_dir($to_remove)) { - return @unlink($object); - } - } + pts_remove($to_remove, $ignore_files); - if(is_dir($object)) - { - $directory = @dir($object); - while(($entry = $directory->read()) !== false) - { - if($entry != "." && $entry != "..") - { - pts_remove($object . "/" . $entry, $ignore_files); - } + //if(count(glob($to_remove . "/*")) == 0) + //{ + @rmdir($object); + //} } - $directory->close(); } - - return @rmdir($object); } function pts_copy($from, $to) { -- cgit