Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small thing, but can you reformat this method to follow PSR standards?

{
$dir = opendir($src);
@mkdir($dst);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably check the output of this method here, to avoid hard to debug errors down the line.

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