// Path: src/main/java/de/idrinth/stellaris/modtools/process/ProcessTask.java
// public interface ProcessTask {
// 
//     List<ProcessTask> handle(EntityManager manager) throws Exception;
//     String getIdentifier();
// }
// 
// Path: src/main/java/de/idrinth/stellaris/modtools/filesystem/FileExtensions.java
// public class FileExtensions {
// 
//     private static final String[] PATCH = "txt,yml,asset,csv,gfx,shader,fxh,gui".split(",");
//     private static final String[] REPLACE = "wav,ogg,ods,dds,bmp,png,psd,jpg,ani,cur,ttf,fnt,tga,otf,anim,mesh".split(",");
// 
//     private FileExtensions() {
//         //this is a static class only
//     }
// 
//     public static boolean isPatchable(String filename) {
//         return isInList(PATCH, filename);
//     }
// 
//     public static boolean isReplaceable(String filename) {
//         return isInList(REPLACE, filename);
//     }
// 
//     public static String[] getPatchable() {
//         return PATCH;
//     }
// 
//     public static String[] getReplaceable() {
//         return REPLACE;
//     }
// 
//     private static boolean isInList(String[] list, String filename) {
//         for (String ext : list) {
//             if (filename.endsWith("."+ext)) {
//                 return true;
//             }
//         }
//         return false;
//     }
// }


import de.idrinth.stellaris.modtools.process.ProcessTask;
import de.idrinth.stellaris.modtools.filesystem.FileExtensions;
import java.io.File;
import java.io.IOException;
import java.util.List;
import javax.persistence.EntityManager;
import org.apache.commons.collections4.iterators.EnumerationIterator;
import org.apache.commons.collections4.iterators.IteratorIterable;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipFile;
import org.apache.commons.io.IOUtils;
/*
 * Copyright (C) 2017 Björn Büttner
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package de.idrinth.stellaris.modtools.process1datacollection;


class ZipContentParser extends Files {

    private final File file;

    public ZipContentParser(String modConfigName, File file) {
        super(modConfigName);
        this.file = file;
    }

    protected void handleSingleZipEntry(ZipFile zip, ZipArchiveEntry entry, EntityManager manager) throws IOException {
        if (entry.isDirectory() || !(entry.getName().contains("/") || entry.getName().contains("\\"))) {
            return;
        }
        if (FileExtensions.isPatchable(entry.getName())) {
            addToFiles(entry.getName(), IOUtils.toString(zip.getInputStream(entry), "utf-8"), manager);
            return;
        }
// Path: src/main/java/de/idrinth/stellaris/modtools/process/ProcessTask.java
// public interface ProcessTask {
// 
//     List<ProcessTask> handle(EntityManager manager) throws Exception;
//     String getIdentifier();
// }
// 
// Path: src/main/java/de/idrinth/stellaris/modtools/filesystem/FileExtensions.java
// public class FileExtensions {
// 
//     private static final String[] PATCH = "txt,yml,asset,csv,gfx,shader,fxh,gui".split(",");
//     private static final String[] REPLACE = "wav,ogg,ods,dds,bmp,png,psd,jpg,ani,cur,ttf,fnt,tga,otf,anim,mesh".split(",");
// 
//     private FileExtensions() {
//         //this is a static class only
//     }
// 
//     public static boolean isPatchable(String filename) {
//         return isInList(PATCH, filename);
//     }
// 
//     public static boolean isReplaceable(String filename) {
//         return isInList(REPLACE, filename);
//     }
// 
//     public static String[] getPatchable() {
//         return PATCH;
//     }
// 
//     public static String[] getReplaceable() {
//         return REPLACE;
//     }
// 
//     private static boolean isInList(String[] list, String filename) {
//         for (String ext : list) {
//             if (filename.endsWith("."+ext)) {
//                 return true;
//             }
//         }
//         return false;
//     }
// }


// Path: src/main/java/de/idrinth/stellaris/modtools/process1datacollection/ZipContentParser.java
import de.idrinth.stellaris.modtools.process.ProcessTask;
import de.idrinth.stellaris.modtools.filesystem.FileExtensions;
import java.io.File;
import java.io.IOException;
import java.util.List;
import javax.persistence.EntityManager;
import org.apache.commons.collections4.iterators.EnumerationIterator;
import org.apache.commons.collections4.iterators.IteratorIterable;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipFile;
import org.apache.commons.io.IOUtils;

/*
 * Copyright (C) 2017 Björn Büttner
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package de.idrinth.stellaris.modtools.process1datacollection;


class ZipContentParser extends Files {

    private final File file;

    public ZipContentParser(String modConfigName, File file) {
        super(modConfigName);
        this.file = file;
    }

    protected void handleSingleZipEntry(ZipFile zip, ZipArchiveEntry entry, EntityManager manager) throws IOException {
        if (entry.isDirectory() || !(entry.getName().contains("/") || entry.getName().contains("\\"))) {
            return;
        }
        if (FileExtensions.isPatchable(entry.getName())) {
            addToFiles(entry.getName(), IOUtils.toString(zip.getInputStream(entry), "utf-8"), manager);
            return;
        }
        if (FileExtensions.isReplaceable(entry.getName())) {