diff --git a/src/Naneau/Obfuscator/Console/Command/ObfuscateCommand.php b/src/Naneau/Obfuscator/Console/Command/ObfuscateCommand.php index 3d3f1dd..139eb24 100644 --- a/src/Naneau/Obfuscator/Console/Command/ObfuscateCommand.php +++ b/src/Naneau/Obfuscator/Console/Command/ObfuscateCommand.php @@ -171,19 +171,38 @@ public function getObfuscator() **/ private function copyDir($from, $to) { - // FIXME implement native copy - $output = array(); - $return = 0; - $command = sprintf('cp -rf %s %s', $from, $to); - - exec($command, $output, $return); - - if ($return !== 0) { + $this->copyDirectory($from, $to); + + if (!is_dir($to)) { throw new \Exception('Could not copy directory'); } - + return $this; } + + /** + * Recursively copy a directory + * + * @param string $src + * @param string $dst + * @return void + **/ + private function copyDirectory($src,$dst) + { + $dir = opendir($src); + @mkdir($dst); + while(false !== ( $file = readdir($dir)) ) { + if (( $file != '.' ) && ( $file != '..' )) { + if ( is_dir($src . '/' . $file) ) { + $this->copyDirectory($src . '/' . $file,$dst . '/' . $file); + } + else { + copy($src . '/' . $file,$dst . '/' . $file); + } + } + } + closedir($dir); + } /** * Finalize the container