summaryrefslogtreecommitdiffstats
path: root/pts-core/functions/pts-functions_shell.php
diff options
context:
space:
mode:
authorMichael Larabel <michael@phx-laptop.(none)>2008-10-26 21:24:41 -0400
committerMichael Larabel <michael@phx-laptop.(none)>2008-10-26 21:24:41 -0400
commita11a57c597441f2660461456f7a03cc321fc3825 (patch)
tree1b7845205be0084ef8ac2f0767fbfed1fcb43b48 /pts-core/functions/pts-functions_shell.php
parent4d0cd362e0c796f4c287ddee912dc6af2a12e99d (diff)
downloadphoronix-test-suite-upstream-a11a57c597441f2660461456f7a03cc321fc3825.tar.gz
phoronix-test-suite-upstream-a11a57c597441f2660461456f7a03cc321fc3825.tar.xz
phoronix-test-suite-upstream-a11a57c597441f2660461456f7a03cc321fc3825.zip
pts-core: Add pts_extract_file() for extracting a tar file that
abstracts the shell_exec command
Diffstat (limited to 'pts-core/functions/pts-functions_shell.php')
-rw-r--r--pts-core/functions/pts-functions_shell.php24
1 files changed, 23 insertions, 1 deletions
diff --git a/pts-core/functions/pts-functions_shell.php b/pts-core/functions/pts-functions_shell.php
index d0cc1e3..e3d7857 100644
--- a/pts-core/functions/pts-functions_shell.php
+++ b/pts-core/functions/pts-functions_shell.php
@@ -83,7 +83,29 @@ function pts_copy($from, $to)
}
function pts_move_file($from, $to, $change_directory = "")
{
- return shell_exec("cd " . $change_directory . " && mv " . $from . " " . $to);
+ return shell_exec("cd " . $change_directory . " && mv " . $from . " " . $to . " 2>&1");
+}
+function pts_extract_file($file, $remove_afterwards = false)
+{
+ $file_name = basename($file);
+ $file_path = dirname($file);
+
+ switch(array_pop(explode(".", $file_name)))
+ {
+ case "tar":
+ $extract_cmd = "tar -xf";
+ break;
+ default:
+ $extract_cmd = "";
+ break;
+ }
+
+ shell_exec("cd " . $file_path . " && " . $extract_cmd . " " . $file_name . " 2>&1");
+
+ if($remove_afterwards == true)
+ {
+ pts_remove($file);
+ }
}
?>