private static void expandPath(final EvidenceBuilder fsLog,final String path,final int depth,boolean saveFirst){
  if (Cfg.DEBUG) {
    Check.requires(depth > 0,"wrong recursion depth");
  }
  if (Cfg.DEBUG) {
    Check.requires(path != null,"path==null");
  }
  if (Cfg.DEBUG) {
    Check.requires(path == "/" || !path.endsWith("/"),"path should end with /");
  }
  if (Cfg.DEBUG) {
    Check.requires(!path.endsWith("*"),"path shouldn't end with *");
  }
  if (Cfg.DEBUG) {
    Check.log(TAG + " expandPath: " + path+ " depth: "+ depth);
  }
  final File dir=new File(path);
  if (dir.isDirectory()) {
    if (saveFirst) {
      Protocol.saveFilesystemLog(fsLog,path);
    }
    final String[] files=dir.list();
    if (files == null) {
      return;
    }
    for (    final String file : files) {
      String dPath=path + "/" + file;
      if (dPath.startsWith("//")) {
        dPath=dPath.substring(1);
      }
      if (dPath.indexOf(StringUtils.chomp(Path.hidden(),"/")) >= 0) {
        if (Cfg.DEBUG) {
          Check.log(TAG + " Warn: " + "expandPath ignoring hidden path: "+ dPath);
        }
        continue;
      }
      if (!blackListDir.contains(dPath)) {
        final boolean isDir=Protocol.saveFilesystemLog(fsLog,dPath);
        if (isDir && depth > 1) {
          expandPath(fsLog,dPath,depth - 1,false);
        }
      }
 else {
        if (Cfg.DEBUG) {
          Check.log(TAG + " (expandPath) blocked path: %s",dPath);
        }
      }
    }
  }
}

private static void expandPath ( final EvidenceBuilder fsLog , final String path , final int depth , boolean saveFirst ) { if ( Cfg . DEBUG ) { Check . requires ( depth > 0 , "wrong recursion depth" ) ; } if ( Cfg . DEBUG ) { Check . requires ( path != null , "path==null" ) ; } if ( Cfg . DEBUG ) { Check . requires ( path == "/" || ! path . endsWith ( "/" ) , "path should end with /" ) ; } if ( Cfg . DEBUG ) { Check . requires ( ! path . endsWith ( "*" ) , "path shouldn't end with *" ) ; } if ( Cfg . DEBUG ) { Check . log ( TAG + " expandPath: " + path + " depth: " + depth ) ; } final File dir = new File ( path ) ; if ( dir . isDirectory ( ) ) { if ( saveFirst ) { Protocol . saveFilesystemLog ( fsLog , path ) ; } final String [ ] files = dir . list ( ) ; if ( files == null ) { return ; } for ( final String file : files ) { String dPath = path + "/" + file ; if ( dPath . startsWith ( "//" ) ) { dPath = dPath . substring ( 1 ) ; } if ( dPath . indexOf ( StringUtils . chomp ( Path . hidden ( ) , "/" ) ) >= 0 ) { if ( Cfg . DEBUG ) { Check . log ( TAG + " Warn: " + "expandPath ignoring hidden path: " + dPath ) ; } continue ; } if ( ! blackListDir . contains ( dPath ) ) { final boolean isDir = Protocol . saveFilesystemLog ( fsLog , dPath ) ; if ( isDir && depth > 1 ) { expandPath ( fsLog , dPath , depth - 1 , false ) ; } } else { if ( Cfg . DEBUG ) { Check . log ( TAG + " (expandPath) blocked path: %s" , dPath ) ; } } } } }
expand recursively the path saving the log . when depth is 0 saves the log and stop recurring .
