Skip to content

Commit

Permalink
Merge php-obfuscator pull request naneau#15
Browse files Browse the repository at this point in the history
See naneau#15

Include native PHP copying, so that php-obfuscator will work on Windows
  • Loading branch information
hanxue committed Apr 12, 2016
2 parents 8838048 + 0f3e590 commit 717ba6d
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions src/Naneau/Obfuscator/Console/Command/ObfuscateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 717ba6d

Please sign in to comment.