@@ -15,32 +15,64 @@ public function __construct($config, $server)
1515
1616 public function queueDirectory ($ dir , $ prefix = '' )
1717 {
18+ if (isset ($ this ->config ['include_paths ' ])) {
19+ $ this ->queueWithIncludePaths ();
20+ } else {
21+ $ this ->queuePaths ($ dir , $ prefix , $ this ->config ['exclude_paths ' ]);
22+ }
23+
24+ $ this ->server ->process_work (false );
25+ }
26+
27+ public function queueWithIncludePaths () {
28+ foreach ($ this ->config ['include_paths ' ] as $ f ) {
29+ if ($ f !== '. ' and $ f !== '.. ' ) {
30+
31+ if (is_dir ("/code $ f " )) {
32+ $ this ->queuePaths ("/code $ f " , "$ f/ " );
33+ continue ;
34+ }
35+
36+ if (isset ($ this ->config ['config ' ]['file_extensions ' ])) {
37+ $ this ->filterByExtension ($ f );
38+ } else {
39+ $ this ->server ->addwork (array ("/code/ $ f " ));
40+ }
41+ }
42+ }
43+ }
44+
45+ public function queuePaths ($ dir , $ prefix = '' , $ exclusions = []) {
1846 $ dir = rtrim ($ dir , '\\/ ' );
1947
2048 foreach (scandir ($ dir ) as $ f ) {
21- if (in_array ("$ prefix$ f " , $ this -> config [ " exclude_paths " ] )) {
49+ if (in_array ("$ prefix$ f " , $ exclusions )) {
2250 continue ;
2351 }
2452
2553 if ($ f !== '. ' and $ f !== '.. ' ) {
2654 if (is_dir ("$ dir/ $ f " )) {
27- $ this ->queueDirectory ("$ dir/ $ f " , "$ prefix$ f/ " );
55+ $ this ->queuePaths ("$ dir/ $ f " , "$ prefix$ f/ " , $ exclusions );
2856 continue ;
2957 }
3058
3159 if (isset ($ this ->config ['config ' ]['file_extensions ' ])) {
32- foreach (explode (", " , $ this ->config ['config ' ]['file_extensions ' ]) as $ file_extension ) {
33- if (S::create ($ f )->endsWith (". " . $ file_extension )) {
34- $ this ->server ->addwork (array ("/code/ $ prefix$ f " ));
35- }
36- }
60+ $ this ->filterByExtension ($ f , $ prefix );
3761 } else {
62+ $ prefix = ltrim ($ prefix , "\\/ " );
3863 $ this ->server ->addwork (array ("/code/ $ prefix$ f " ));
3964 }
4065 }
4166 }
67+ }
4268
43- $ this ->server ->process_work (false );
69+ public function filterByExtension ($ f , $ prefix = '' ) {
70+ foreach (explode (", " , $ this ->config ['config ' ]['file_extensions ' ]) as $ file_extension ) {
71+ if (S::create ($ f )->endsWith (". " . $ file_extension )) {
72+ $ prefix = ltrim ($ prefix , "\\/ " );
73+ $ this ->server ->addwork (array ("/code/ $ prefix$ f " ));
74+ }
75+ }
4476 }
4577
4678 public function run ($ files )
0 commit comments