private boolean checkFileLevelRelativeToRoot ( Path filePath , int depth ) { if ( filePath == null ) { return false ; } Path path = filePath ; for ( int i = 0 ; i < depth - 1 ; i ++ ) { path = path . getParent ( ) ; } if ( ! path . getName ( ) . equals ( folderName ) ) { return false ; } return true ; }
Helper to check if a file has proper hierarchy .