private long addFilesInDir ( Path path , List < FileStatus > files , boolean logExcludedFiles ) throws IOException { final FileSystem fs = path . getFileSystem ( ) ; long length = 0 ; for ( FileStatus dir : fs . listStatus ( path ) ) { if ( dir . isDir ( ) ) { if ( acceptFile ( dir ) && enumerateNestedFiles ) { length += addFilesInDir ( dir . getPath ( ) , files , logExcludedFiles ) ; } else { if ( logExcludedFiles && LOG . isDebugEnabled ( ) ) { LOG . debug ( "Directory " + dir . getPath ( ) . toString ( ) + " did not pass the file-filter and is excluded." ) ; } } } else { if ( acceptFile ( dir ) ) { files . add ( dir ) ; length += dir . getLen ( ) ; testForUnsplittable ( dir ) ; } else { if ( logExcludedFiles && LOG . isDebugEnabled ( ) ) { LOG . debug ( "Directory " + dir . getPath ( ) . toString ( ) + " did not pass the file-filter and is excluded." ) ; } } } } return length ; }
Enumerate all files in the directory and recursive if enumerateNestedFiles is true .