diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2011-11-27 11:29:44 -0500 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2011-11-27 11:29:44 -0500 |
commit | de5cb6329b4e6a4c409d1418f16a3488a53ca953 (patch) | |
tree | 3a5af4ef0fd42e4f4904326d2cc94d53582e028e /shell/bin/cp.php | |
parent | 76ead734626996f82caddaca57dc2f84243b0947 (diff) |
Diffstat (limited to 'shell/bin/cp.php')
-rw-r--r-- | shell/bin/cp.php | 72 |
1 files changed, 39 insertions, 33 deletions
diff --git a/shell/bin/cp.php b/shell/bin/cp.php index 4a6cfae..8f47970 100644 --- a/shell/bin/cp.php +++ b/shell/bin/cp.php @@ -1,33 +1,39 @@ -<?php -class p_cp extends prog { - /* This method (recurse_copy) was written by gimmicklessgpt@gmail.com - * and posted to the PHP manual comments section on 20-May-2009 11:04 - */ - function recurse_copy($src,$dst) { - $dir = opendir($src); - @mkdir($dst); - while(false !== ( $file = readdir($dir)) ) { - if (( $file != '.' ) && ( $file != '..' )) { - if ( is_dir($src . '/' . $file) ) { - recurse_copy($src . '/' . $file,$dst . '/' . $file); - } - else { - copy($src . '/' . $file,$dst . '/' . $file); - } - } - } - closedir($dir); - } - - public static function main($args, $env) { - $me = array_shift($args); - $flags = ''; - while (strstr($args[0],0,1) == '-') { - $flags .= array_shift($args); - } - $flags = preg_replace('/[ -]/','',$flags); - if (strpos($flags,'r')===false) { copy($args[0],$args[1]); } - else { recurse_copy($args[0],$args[1]); } - } -} - +<?php
+class p_cp extends prog {
+ /* This method (recurse_copy) was written by gimmicklessgpt@gmail.com
+ * and posted to the PHP manual comments section on 20-May-2009 11:04
+ */
+ static function recurse_copy($src,$dst) {
+ //echo 'recurse_copy('.$src.', '.$dst.");\n";
+ $dir = opendir($src);
+ @mkdir($dst);
+ while(false !== ( $file = readdir($dir)) ) {
+ if (( $file != '.' ) && ( $file != '..' )) {
+ if ( is_dir($src . '/' . $file) ) {
+ self::recurse_copy($src . '/' . $file,$dst . '/' . $file);
+ }
+ else {
+ self::copy( $src.'/'.$file , $dst.'/'.$file );
+ }
+ }
+ }
+ closedir($dir);
+ }
+
+ static function copy($src,$dst) {
+ //echo 'copy('.$src.', '.$dst.");\n";
+ copy($src, $dst);
+ }
+
+ public static function main($args, $env) {
+ $me = array_shift($args);
+ $flags = '';
+ while (substr($args[0],0,1) == '-') {
+ $flags .= array_shift($args);
+ }
+ $flags = preg_replace('/[ -]/','',$flags);
+ if (strpos($flags,'r')===false) { self::copy($args[0],$args[1]); }
+ else { self::recurse_copy($args[0],$args[1]); }
+ }
+}
+
|