File tree Expand file tree Collapse file tree 1 file changed +28
-9
lines changed
src/Naneau/Obfuscator/Console/Command Expand file tree Collapse file tree 1 file changed +28
-9
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments