summaryrefslogtreecommitdiffstats
path: root/pts-core/functions/pts-functions_shell.php
diff options
context:
space:
mode:
Diffstat (limited to 'pts-core/functions/pts-functions_shell.php')
-rw-r--r--pts-core/functions/pts-functions_shell.php39
1 files changed, 18 insertions, 21 deletions
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)
{