Skip to content

Commit 717ba6d

Browse files
committed
Merge php-obfuscator pull request naneau#15
See naneau#15 Include native PHP copying, so that php-obfuscator will work on Windows
2 parents 8838048 + 0f3e590 commit 717ba6d

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

src/Naneau/Obfuscator/Console/Command/ObfuscateCommand.php

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,19 +171,38 @@ public function getObfuscator()
171171
**/
172172
private function copyDir($from, $to)
173173
{
174-
// FIXME implement native copy
175-
$output = array();
176-
$return = 0;
177-
$command = sprintf('cp -rf %s %s', $from, $to);
178-
179-
exec($command, $output, $return);
180-
181-
if ($return !== 0) {
174+
$this->copyDirectory($from, $to);
175+
176+
if (!is_dir($to)) {
182177
throw new \Exception('Could not copy directory');
183178
}
184-
179+
185180
return $this;
186181
}
182+
183+
/**
184+
* Recursively copy a directory
185+
*
186+
* @param string $src
187+
* @param string $dst
188+
* @return void
189+
**/
190+
private function copyDirectory($src,$dst)
191+
{
192+
$dir = opendir($src);
193+
@mkdir($dst);
194+
while(false !== ( $file = readdir($dir)) ) {
195+
if (( $file != '.' ) && ( $file != '..' )) {
196+
if ( is_dir($src . '/' . $file) ) {
197+
$this->copyDirectory($src . '/' . $file,$dst . '/' . $file);
198+
}
199+
else {
200+
copy($src . '/' . $file,$dst . '/' . $file);
201+
}
202+
}
203+
}
204+
closedir($dir);
205+
}
187206

188207
/**
189208
* Finalize the container

0 commit comments

Comments
 (0)