private static List < CopyPath > expandDirectories ( FileSystem fs , List < Path > paths , Path dstPath ) throws IOException { List < CopyPath > newList = new ArrayList < CopyPath > ( ) ; FileSystem dstFs = dstPath . getFileSystem ( defaultConf ) ; boolean isDstFile = false ; try { FileStatus dstPathStatus = dstFs . getFileStatus ( dstPath ) ; if ( ! dstPathStatus . isDir ( ) ) { isDstFile = true ; } } catch ( FileNotFoundException e ) { isDstFile = true ; } for ( Path path : paths ) { FileStatus pathStatus = fs . getFileStatus ( path ) ; if ( ! pathStatus . isDir ( ) ) { // This is the case where the destination is a file, in this case, we // allow only a single source file. This check has been done below in // FastCopy#parseFiles(List, String[]) if ( isDstFile ) { newList . add ( new CopyPath ( path , dstPath ) ) ; } else { newList . add ( new CopyPath ( path , new Path ( dstPath , path . getName ( ) ) ) ) ; } } else { // If we are copying /a/b/c into /x/y/z and 'z' does not exist, we // create the structure /x/y/z/f*, where f* represents all files and // directories in c/ Path rootPath = dstPath ; // This ensures if we copy a directory like /a/b/c to a directory // /x/y/z/, we will create the directory structure /x/y/z/c, if 'z' // exists. if ( dstFs . exists ( dstPath ) ) { rootPath = new Path ( dstPath , pathStatus . getPath ( ) . getName ( ) ) ; } getDirectoryListing ( pathStatus , fs , newList , rootPath ) ; } } return newList ; }
Get the listing of all files under the given directories .