/** * Recursive method to add files in a pack. * * @param file The file to add. * @param targetdir The relative path to the parent. * @param osList The target OS constraints. * @param override Overriding behaviour. * @param pack Pack to be packed into * @param additionals Map which contains additional data * @exception FileNotFoundException if the file does not exist */ protected void addRecursively( File file, String targetdir, List osList, int override, PackInfo pack, Map additionals) throws IOException { String targetfile = targetdir + "/" + file.getName(); if (!file.isDirectory()) pack.addFile(file, targetfile, osList, override, additionals); else { File[] files = file.listFiles(); if (files.length == 0) // The directory is empty so must be added pack.addFile(file, targetfile, osList, override, additionals); else { // new targetdir = targetfile; for (int i = 0; i < files.length; i++) addRecursively(files[i], targetfile, osList, override, pack, additionals); } } }