private void scanForChildren ( ) { if ( debug ) System . out . printf ( "DirectoryBuilder.scanForChildren on %s " , dir ) ; int count = 0 ; try ( DirectoryStream < Path > ds = Files . newDirectoryStream ( dir ) ) { for ( Path p : ds ) { BasicFileAttributes attr = Files . readAttributes ( p , BasicFileAttributes . class ) ; if ( attr . isDirectory ( ) ) { children . add ( new DirectoryBuilder ( topCollectionName , p , attr , suffix ) ) ; if ( debug && ( ++ count % 10 == 0 ) ) System . out . printf ( "%d " , count ) ; } } } catch ( IOException e ) { e . printStackTrace ( ) ; } if ( debug ) System . out . printf ( "done=%d%n" , count ) ; childrenConstructed = true ; }
Scan for subdirectories make each into a DirectoryBuilder and add as a child