<commit_before>package preservetools.utilities;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

import preservetools.files.executables.CdRom_IsoImageChecker;

public class ListsFiles {
	/**
	 * lists all files and directories in given directory
	 * 
	 * @param
	 * @return: ArrayList<File> of all found files and subfolders
	 * @throws IOException
	 * 
	 */
	public static ArrayList<File> getPaths(File file, ArrayList<File> list)
			throws IOException {
		if (file == null || list == null || !file.isDirectory())
			return null;
		File[] fileArr = file.listFiles();
		for (File f : fileArr) {
			// TODO If a folder is chosen that cannot be searched/read, e. g.
			// C:/, the tool runs into issues
			if (f.isDirectory()) {
		
				if (!f.getName().toLowerCase().contains ("adobereader")) {
				getPaths(f, list);
				}
				
				else {
					System.out.println ("Adobe Reader Software Folder:" + f.toString().toLowerCase());
				}
			}
			if (!f.isDirectory()) { // adds only non-directories (=files) to the
									// ArrayList of Files

				String extension = preservetools.files.GenericFileAnalysis
						.getFileExtension(f);

				if (extension != null) {

					// TODO: What about .tar-files etc?
					if (extension.equals("zip")) {				
						try {
							ZipFile zf = new ZipFile(f.toString());
							Enumeration<? extends ZipEntry> e = zf.entries();
							ZipEntry ze;
							while (e.hasMoreElements()) {
								ze = e.nextElement();						

								if (!ze.isDirectory()) {
									File CompFile = new File(ze.toString());
									list.add(CompFile);
								}

							}
							zf.close();
						}

						catch (Exception e) {
							// TODO: After this exception is caused, the adding
							// of the rest of the files in the zip folder stops
							CdRom_IsoImageChecker.filesExecutable.println(f
									+ " causes an Exception" + e);
						}
					}

					else {		

						list.add(f);
					}
				}

				else {
					System.out
							.println("Extension of file could not be extracted "
									+ f);
					list.add(f);
				}
				
				//remove all Adobe Reader setup files from list
				
				String acrobatreadertest = f.toString().toLowerCase();
				
				//TODO: ingore complete folder named "AdobeReader"
				
				if ((acrobatreadertest.contains("adberdr")) || (acrobatreadertest.contains("acroread")) || (acrobatreadertest.contains("adobe_acrobat_reader"))) {
					System.out.println ("Adobe Reader Software:" + f.toString().toLowerCase());
					 list.remove(f);
				}
				
			}
		}

		return list;
	}
}<commit_msg>changed function ListsFiles because it should be used generically<commit_after>package preservetools.utilities;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

import preservetools.files.executables.CdRom_IsoImageChecker;

public class ListsFiles {
	/**
	 * lists all files and directories in given directory
	 * 
	 * @param
	 * @return: ArrayList<File> of all found files and subfolders
	 * @throws IOException
	 * 
	 */
	public static ArrayList<File> getPaths(File file, ArrayList<File> list)
			throws IOException {
		if (file == null || list == null || !file.isDirectory())
			return null;
		File[] fileArr = file.listFiles();
		for (File f : fileArr) {
			// TODO If a folder is chosen that cannot be searched/read, e. g.
			// C:/, the tool runs into issues

			// TODO: This cannot be done in this generic method. It's only for the Cdom_IsoImageChecker
			/*
			 * if (f.isDirectory()) { if (!f.getName().toLowerCase().contains
			 * ("adobereader")) { getPaths(f, list); }
			 * 
			 * else { System.out.println ("Adobe Reader Software Folder:" +
			 * f.toString().toLowerCase()); }
			 * 
			 * }
			 */
			if (!f.isDirectory()) { // adds only non-directories (=files) to the
									// ArrayList of Files

				String extension = preservetools.files.GenericFileAnalysis
						.getFileExtension(f);

				if (extension != null) {

					// TODO: What about .tar-files etc?
					if (extension.equals("zip")) {
						try {
							ZipFile zf = new ZipFile(f.toString());
							Enumeration<? extends ZipEntry> e = zf.entries();
							ZipEntry ze;
							while (e.hasMoreElements()) {
								ze = e.nextElement();

								if (!ze.isDirectory()) {
									File CompFile = new File(ze.toString());
									list.add(CompFile);
								}

							}
							zf.close();
						}

						catch (Exception e) {
							// TODO: After this exception is caused, the adding
							// of the rest of the files in the zip folder stops
							CdRom_IsoImageChecker.filesExecutable.println(f
									+ " causes an Exception" + e);
						}
					}

					else {

						list.add(f);
					}
				}

				else {
					System.out
							.println("Extension of file could not be extracted "
									+ f);
					list.add(f);
				}

				// remove all Adobe Reader setup files from list

				String acrobatreadertest = f.toString().toLowerCase();

				// TODO: ingore complete folder named "AdobeReader"

				if ((acrobatreadertest.contains("adberdr"))
						|| (acrobatreadertest.contains("acroread"))
						|| (acrobatreadertest.contains("adobe_acrobat_reader"))) {
					System.out.println("Adobe Reader Software:"
							+ f.toString().toLowerCase());
					list.remove(f);
				}

			}
		}

		return list;
	}
}
{'fraction_non_alphanumeric': 0.1268970561345767, 'fraction_numerical': 0.0, 'mean_word_length': 2.5313105229180115, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6271423', 'n_tokens_mistral': 2263, 'n_tokens_neox': 1646, 'n_words': 448}