Browse Source

Fix für endlosschleife beim einlesen IZPL
WIP im WPCMgr
Gitigronier-datei aktualisiert

LH 8 years ago
parent
commit
88edef403d

+ 61 - 60
.gitignore

@@ -1,60 +1,61 @@
-.gradle
-build/
-# Ignore Gradle GUI config
-gradle-app.setting
-
-
-*.class
-# Mobile Tools for Java (J2ME)
-.mtj.tmp/
-# Package Files #
-*.jar
-*.war
-*.ear
-# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
-hs_err_pid*
-nbproject/
-nbproject/private/
-build/
-nbbuild/
-dist/*
-nbdist/
-nbactions.xml
-nb-configuration.xml
-.nb-gradle-properties
-
-# Windows image file caches
-Thumbs.db
-ehthumbs.db
-# Folder config file
-Desktop.ini
-# Recycle Bin used on file shares
-$RECYCLE.BIN/
-# Windows Installer files
-*.cab
-*.msi
-*.msm
-*.msp
-# Windows shortcuts
-*.lnk
-/.nb-gradle/private/
-
-/.nb-gradle
-#iZsetup-temporary files
-izsetup.izbundle
-!IZSetup/distPackagerBase/ZZZ_sfxmod.jar
-!IZSetup/distPackagerBase/engine/iZsetupLauncher.jar
-!IZSetup/distPackagerBase/64b/engine/iZsetupLauncher.jar
-!IZSetup/distPackagerBase/64b/ZZZ_sfxmod.jar
-!IZSetup/distPackagerBase/dist/
-!IZSetup/distPackagerBase/64b/dist/
-IZSetup/distPackagerBase/dist/iZsetup_setup.jar
-IZSetup/distPackagerBase/64b/dist/iZsetup_setup.jar
-#special nonmaven libs
-!**/lib/*
-**/.nb-gradle/
-**/auxy/*
-#petzende files
-*.log
-!gradle/wrapper/*
-/IZPL-A/IZPL/.nb-gradle/private/
+.gradle
+build/
+# Ignore Gradle GUI config
+gradle-app.setting
+
+
+*.class
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+# Package Files #
+*.jar
+*.war
+*.ear
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+nbproject/
+nbproject/private/
+build/
+nbbuild/
+dist/*
+nbdist/
+nbactions.xml
+nb-configuration.xml
+.nb-gradle-properties
+
+# Windows image file caches
+Thumbs.db
+ehthumbs.db
+# Folder config file
+Desktop.ini
+# Recycle Bin used on file shares
+$RECYCLE.BIN/
+# Windows Installer files
+*.cab
+*.msi
+*.msm
+*.msp
+# Windows shortcuts
+*.lnk
+/.nb-gradle/private/
+
+/.nb-gradle
+#iZsetup-temporary files
+izsetup.izbundle
+!IZSetup/distPackagerBase/ZZZ_sfxmod.jar
+!IZSetup/distPackagerBase/engine/iZsetupLauncher.jar
+!IZSetup/distPackagerBase/64b/engine/iZsetupLauncher.jar
+!IZSetup/distPackagerBase/64b/ZZZ_sfxmod.jar
+!IZSetup/distPackagerBase/dist/
+!IZSetup/distPackagerBase/64b/dist/
+IZSetup/distPackagerBase/dist/iZsetup_setup.jar
+IZSetup/distPackagerBase/64b/dist/iZsetup_setup.jar
+#special nonmaven libs
+!**/lib/*
+**/.nb-gradle/
+**/auxy/*
+#petzende files
+*.log
+!gradle/wrapper/*
+/IZPL-A/IZPL/.nb-gradle/private/
+*.stackdump

+ 83 - 80
WPCMGr/build.gradle

@@ -1,80 +1,83 @@
-defaultTasks 'distZip'
-
-apply plugin: 'java'
-apply plugin: 'application'
-apply from: "$rootDir/utils/IO.gradle"
-
-sourceCompatibility = 1.8
-version = 'SNAPSHOT'
-mainClassName = 'de.nplusc.izc.Utilities.WPCMgr.Main'
-
-
-jar{
-	manifest{
-		attributes 'Implementation-Title': 'iZToolKit',
-					'Implementation-Version': 'SNAPSHOT',
-					'Main-Class': 'de.nplusc.izc.iZpl.Builder'
-					
-	}
-}
-
-repositories{
-	jcenter()
-}
-
-compileJava {
-options.compilerArgs << '-Xlint:none'
-
-options.compilerArgs << '-Xlint:-deprecation'
-
-options.compilerArgs << '-XDignore.symbol.file'
-}
-startScripts << { 
-
-  def startScriptDir = outputDir.getAbsolutePath()
-  def winStartScript = startScriptDir + "/" + applicationName + ".bat"
-  def winStartScriptCopy = startScriptDir + "/" + applicationName + "c.bat"
-  def overwriteExistingFile = true
-  copyFile(winStartScript, winStartScriptCopy, overwriteExistingFile)
-
-  modifyFile(winStartScript) {
-    // javaw.exe doesn't have a console
-    if(it.contains("java.exe")){
-      return it.replace("java.exe", "javaw.exe")
-    }
-    // Command that launches the app
-    else if(it.startsWith("\"%JAVA_EXE%\" %DEFAULT_JVM_OPTS%")){
-      return "start \"\" /b " + it
-    }
-    // Leave the line unchanged
-    else{
-      return it
-    }
-  }
-}
-distZip {
-  // Include the additional start script
-  into(project.name+"-"+project.version+"/bin/"){
-    from(startScripts.outputDir)
-	include '*c.bat'
-  }
-}
-
-dependencies{
-	compile fileTree(dir: 'lib', include: '*.jar')
-        compile "net.rubygrapefruit:native-platform:0.9"
-	compile "commons-io:commons-io:2.+"
-	compile 'org.apache.commons:commons-exec:1.3'
-	compile "org.yaml:snakeyaml:1.14"
-	compile 'org.ini4j:ini4j:0.5.2'
-	compile 'mysql:mysql-connector-java:5.1.6'
-        compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.1'
-	compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.1'
-	compile group: 'org.apache.logging.log4j', name: 'log4j-iostreams', version: '2.1'
-	compile(project(':ToolKit')) {
-        transitive = false
-    }
-
-
-	
-}
+defaultTasks 'distZip'
+
+apply plugin: 'java'
+apply plugin: 'application'
+apply from: "$rootDir/utils/IO.gradle"
+
+sourceCompatibility = 1.8
+version = 'SNAPSHOT'
+mainClassName = 'de.nplusc.izc.Utilities.WPCMgr.Main'
+
+
+jar{
+	manifest{
+		attributes 'Implementation-Title': 'WPCMgr',
+					'Implementation-Version': 'SNAPSHOT',
+					'Main-Class': 'de.nplusc.izc.iZpl.Builder'
+					
+	}
+}
+
+repositories{
+	jcenter()
+}
+
+compileJava {
+options.compilerArgs << '-Xlint:none'
+
+options.compilerArgs << '-Xlint:-deprecation'
+
+options.compilerArgs << '-XDignore.symbol.file'
+}
+startScripts << { 
+
+  def startScriptDir = outputDir.getAbsolutePath()
+  def winStartScript = startScriptDir + "/" + applicationName + ".bat"
+  def winStartScriptCopy = startScriptDir + "/" + applicationName + "c.bat"
+  def overwriteExistingFile = true
+  copyFile(winStartScript, winStartScriptCopy, overwriteExistingFile)
+
+  modifyFile(winStartScript) {
+    // javaw.exe doesn't have a console
+    if(it.contains("java.exe")){
+      return it.replace("java.exe", "javaw.exe")
+    }
+    // Command that launches the app
+    else if(it.startsWith("\"%JAVA_EXE%\" %DEFAULT_JVM_OPTS%")){
+      return "start \"\" /b " + it
+    }
+    // Leave the line unchanged
+    else{
+      return it
+    }
+  }
+}
+distZip {
+  // Include the additional start script
+  into(project.name+"-"+project.version+"/bin/"){
+    from(startScripts.outputDir)
+	include '*c.bat'
+  }
+}
+
+dependencies{
+	compile fileTree(dir: 'lib', include: '*.jar')
+        compile "net.rubygrapefruit:native-platform:0.9"
+	compile "commons-io:commons-io:2.+"
+	compile 'org.apache.commons:commons-exec:1.3'
+	compile "org.yaml:snakeyaml:1.14"
+	compile 'org.ini4j:ini4j:0.5.2'
+	compile 'mysql:mysql-connector-java:5.1.6'
+        compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.1'
+	compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.1'
+	compile group: 'org.apache.logging.log4j', name: 'log4j-iostreams', version: '2.1'
+        compile 'org.fusesource.jansi:jansi:1.11'
+        compile 'commons-cli:commons-cli:1.3'
+	compile(project(':ToolKit')) {
+        transitive = false
+        compile(project(':external:java-progressbar'))
+    }
+
+
+	
+}

+ 249 - 73
WPCMGr/src/main/java/de/nplusc/izc/Utilities/WPCMgr/Main.java

@@ -1,73 +1,249 @@
-/*
- * Copyright (C) 2015 iZc
- *
- * 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.nplusc.izc.Utilities.WPCMgr;
-
-/**
- *
- * @author LH
- */
-public class Main
-{
-    public static void main(String[] args)
-    {
-        System.out.println(args.length);
-        if (args.length>0)
-        {
-            System.out.println(args[0]);
-            if(args[0].equals("--help")||args[0].equals("-h")||args[0].equals("/?"))
-            {
-                printHelp();
-            }
-            if(args.length>2)
-            {
-                System.out.println(args[1]);
-                System.out.println(args[2]);
-                switch (args[0])
-                {
-                    case "--wpcprocess":
-                        Synchronizer.main(new String[]{args[1],args[2]});
-                        break;
-                    case "--initDirectory":
-                        WPCUtils.initCache(args[1], args[2]);
-                        break;
-                    default:
-                        printHelp();
-                        break;
-                }
-            }
-            return;
-        }
-        printHelp();
-    }
-    
-    private static void printHelp()
-    {
-        System.out.println("Cmdline usage of WPC-Mgr");
-        System.out.println("wpc-mgr.jar [mode] <values>");
-        System.out.println("Modes and its values");
-        System.out.println("--wpcprocess : Processes the given cacheDictory");
-        System.out.println("usage: --wpcprocess P:\\ath\\to\\CacheDir screenWidthxScreenHeight");
-        System.out.println("--initDirectory : initializes a CacheDirectory for being used by wpcprocess");
-        System.out.println("P:\\ath\\to\\CacheDir");
-        System.out.println("T:\\arged\\Directory\\Of\\ProcessedFiles");
-        System.out.println("No parameter:");
-        System.out.println("currently help; later :starts in GUI-Mode to manage the lt opened Cache");
-        
-        
-    }
-}
+/*
+ * Copyright (C) 2015 iZc
+ *
+ * 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.nplusc.izc.Utilities.WPCMgr;
+
+import java.io.FileNotFoundException;
+import java.util.HashMap;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.DefaultParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.OptionGroup;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.config.LoggerConfig;
+
+/**
+ *
+ * @author LH
+ */
+public class Main
+{
+    /*
+    ProgressBar progressBar = ConsoleProgressBar.on(System.out)
+    .withFormat("[:bar] :percent% :elapsed/:total ETA: :eta")
+    .withTotalSteps(500);
+    */
+    private static Logger l;
+    public static void main(String[] args)
+    {
+        CommandLineParser parser = new DefaultParser();
+        Options options = new Options();
+        OptionGroup modes = new OptionGroup();
+        
+        options.addOption("v", "verbose", false, "Enables verbose logging");
+        modes.addOption(OptionBuilder.withLongOpt("process")
+                .withDescription("Process FOLDER")
+                .create("p"));
+        options.addOption(OptionBuilder.withLongOpt("folder")
+                .withDescription("Sets the current WPCache to FOLDER")
+                .hasArg()
+                .withArgName("FOLDER")
+                .create("f"));
+        modes.addOption(OptionBuilder.withLongOpt("initDirectory")
+                .withDescription("init selected wpcache that converts into TARGET")
+                .hasArg()
+                .withArgName("TARGET")
+                .create("i"));
+        modes.addOption(OptionBuilder.withLongOpt("addScreen")
+                .withDescription("add SCREEN with given settings (\"id,xpos,ypos,width,height\") to the screen registry of the selected cache, allows multiple screens to be defined at once. existing Screens with the same ID get overwritten"+
+                        "Alternative Sybtax for screen is \"id,width,height\" to get a screen at default position of 0,0")
+                .hasArgs(Option.UNLIMITED_VALUES)
+                .withArgName("SCREEN")
+                .create());
+        options.addOptionGroup(modes);
+        try
+        {
+            CommandLine cl = parser.parse(options, args);
+            Main.setupLogging(cl.hasOption("verbose"));
+            String folder = "XXX";
+            if (cl.hasOption("folder"))
+            {
+                folder = cl.getOptionValue("folder");
+            }
+            else
+            {
+                throw new ParseException("Folder undefined");
+            }
+            l.trace(folder);
+            if (cl.hasOption("initDirectory"))
+            {
+                String initArg = cl.getOptionValue("initDirectory");
+                WPCUtils.initCache(folder,initArg);
+            }
+            else
+            {
+                if (cl.hasOption("addScreen"))
+                {
+                    String[] screendefs = cl.getOptionValues("addScreen");
+                    
+                    HashMap<String,Object> cfg = WPCUtils.getConfig(folder);
+                    for (String screendef : screendefs)
+                    {
+                        String[] screen = screendef.split(",");
+                        int x=0,y=0;
+                        int w=0,h=0;
+                        try{
+                            if(screen.length==5)
+                            {
+                                x=Integer.valueOf(screen[1]);
+                                y=Integer.valueOf(screen[2]);
+                                w=Integer.valueOf(screen[3]);
+                                h=Integer.valueOf(screen[4]);
+                            }
+                            else if (screen.length==3)
+                            {
+                                w=Integer.valueOf(screen[1]);
+                                h=Integer.valueOf(screen[2]);
+                            }
+                            else
+                            {
+                                throw new ParseException("Malformed screen string: parameter count wrong @ "+screendef);
+                            }
+                            WPCUtils.addMonitor(cfg,screen[0], x, y, w, h);
+                        }
+                        catch(NumberFormatException ex)
+                        {
+                            throw new ParseException("Malformed screen string: Invalid number giveen @ "+screendef);
+                        }
+                    }
+                    WPCUtils.saveConfig(folder, cfg);
+                }
+                else
+                {
+                    if(cl.hasOption("process"))
+                    {
+                        Synchronizer.main(folder);
+                    }
+                    else
+                    {
+                        throw new ParseException("No PARAMS");
+                    }
+                }
+               
+            }
+        }
+        catch (ParseException ex)
+        {
+            String msg = ex.getMessage();
+            System.err.println("Failed to parse the commandline");
+            if(msg!=null)
+            {
+                 System.err.println(msg);
+            }
+            else
+            {
+                 System.err.println("No further details given");
+            }
+            
+            HelpFormatter formatter = new HelpFormatter();
+            formatter.printHelp("wpcmgr", options);
+            System.exit(0);
+        }
+        catch (FileNotFoundException ex)
+        {
+            String msg = ex.getMessage();
+            System.err.println("Failed to parse the commandline, invalid cachedir");
+            if(msg!=null)
+            {
+                 System.err.println(msg);
+            }
+            else
+            {
+                 System.err.println("No further details given");
+            }
+            HelpFormatter formatter = new HelpFormatter();
+            formatter.printHelp("wpcmgr", options);
+            System.exit(0);
+        }
+        
+        /*
+        System.out.println(args.length);
+        if (args.length>0)
+        {
+            System.out.println(args[0]);
+            if(args[0].equals("--help")||args[0].equals("-h")||args[0].equals("/?"))
+            {
+                printHelp();
+            }
+            if(args.length>2)
+            {
+                System.out.println(args[1]);
+                System.out.println(args[2]);
+                switch (args[0])
+                {
+                    case "--wpcprocess":
+                        Synchronizer.main(new String[]{args[1],args[2]});
+                        break;
+                    case "--initDirectory":
+                        
+                        break;
+                    default:
+                        printHelp();
+                        break;
+                }
+            }
+            return;
+        }
+        printHelp();*/
+    }
+    
+    private static void printHelp()
+    {
+        System.out.println("Cmdline usage of WPC-Mgr");
+        System.out.println("wpc-mgr.jar [mode] <values>");
+        System.out.println("Modes and its values");
+        System.out.println("--wpcprocess : Processes the given cacheDictory");
+        System.out.println("usage: --wpcprocess P:\\ath\\to\\CacheDir screenWidthxScreenHeight");
+        System.out.println("--initDirectory : initializes a CacheDirectory for being used by wpcprocess");
+        System.out.println("P:\\ath\\to\\CacheDir");
+        System.out.println("T:\\arged\\Directory\\Of\\ProcessedFiles");
+        System.out.println("No parameter:");
+        System.out.println("currently help; later :starts in GUI-Mode to manage the last opened Cache");
+        
+        
+    }
+    
+        private static void setupLogging(boolean verbose)
+    {
+        l=LogManager.getLogger(Main.class.getName());
+        LoggerContext cx = (LoggerContext) LogManager.getContext(false);
+        org.apache.logging.log4j.core.config.Configuration config = cx.getConfiguration();
+        LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME); 
+        LoggerConfig externalloggerConfig = config.getLoggerConfig("External"); 
+
+        if (verbose)
+        {
+            
+            loggerConfig.setLevel(Level.TRACE);
+            externalloggerConfig.setLevel(Level.TRACE);
+        }
+        else
+        {
+            loggerConfig.setLevel(Level.INFO);
+            externalloggerConfig.setLevel(Level.INFO);
+        }
+        cx.updateLoggers();
+    }
+}

+ 70 - 0
WPCMGr/src/main/java/de/nplusc/izc/Utilities/WPCMgr/Screen.java

@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2016 iZc
+ *
+ * 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.nplusc.izc.Utilities.WPCMgr;
+
+/**
+ *
+ * @author iZc <nplusc.de>
+ */
+public class Screen
+{
+    private final int x,y,w,h;
+    
+    public Screen(int x,int y,int w,int h)
+    {
+        this.x=x;
+        this.y=y;
+        this.w=w;
+        this.h=h;
+    }
+    /**
+     * 
+     * @param other
+     * @return [rx,ry,w,h]
+     */
+    public int[] intersectArea(Screen other)
+    {
+        if((this.x+w<=other.x&&this.y+h<=other.y)
+            ||(other.x+other.w<=w&&other.y+other.h<=h))
+        {
+            return new int[]{0,0,0,0};
+        }
+        if(this.x<other.x)
+        {
+            
+        }
+        else
+        {
+            
+        }
+        return new int[]{0,0};
+    }
+    public int[] intersectArea(int[] basePoint,Screen other)
+    {
+        return new int[]{0,0};
+    }
+    public int[] getPosition()
+    {
+        return null;
+    }
+
+    public int[] getSize()
+    {
+        return null;
+    }
+    
+}

+ 430 - 409
WPCMGr/src/main/java/de/nplusc/izc/Utilities/WPCMgr/Synchronizer.java

@@ -1,409 +1,430 @@
-/*
- * Copyright (C) 2015 iZc
- *
- * 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.nplusc.izc.Utilities.WPCMgr;
-
-import de.nplusc.izc.tools.IOtools.FileTK;
-import de.nplusc.izc.tools.baseTools.Tools;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.LinkedHashMap;
-import java.util.List;
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.Yaml;
-
-/**
- *
- * @author LH
- */
-public class Synchronizer
-{
-    public static void main(String[] args)
-    {
-        String path = "";
-        String res = "";
-        if(args.length>1)
-        {
-        path = args[0];
-        res = args[1];
-        }
-        //DEBUG
-        //path="T:\\wpc";
-        //res="1920x1080";
-        
-        try
-        {
-            folderOptimize(path);
-            LinkedHashMap<String,Object> data = (LinkedHashMap<String,Object>) new Yaml().load(new FileInputStream(path+"\\00_meta\\state.yml"));
-            if(data.get("HEAD")==null)
-            {
-                initPipeLine(path, res);
-            }
-            else
-            {
-                updatePipeLine(path, res);
-            }
-        }
-        catch (FileNotFoundException ex)
-        {
-            ex.printStackTrace();
-        }
-        
-    }
-    
-    public static void initPipeLine(String path,String res)
-    {
-        String[] dirsExist = FileTK.getDirectoryContent(/*args[0]*/path,true);
-        final int pid[] = new int[]{0};
-        List<String[]> cmdQueue = new ArrayList<>();
-        List<String> resultFiles = new ArrayList<>();
-        List<String> packagesInitialized = new ArrayList<>();
-        Arrays.stream(dirsExist).filter(t -> !t.startsWith("00_") && new File(path+"\\" + t).isDirectory()).forEach(t ->
-        {
-            packagesInitialized.add(t);
-            Object[] rv = processPackage(/*args[0]+*/path+"\\" + t, pid[0]++, res);
-            cmdQueue.addAll((List<String[]>) rv[0]);
-            resultFiles.addAll((List<String>) rv[1]);
-        });
-        DumperOptions yamlOptions = new DumperOptions();
-        yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
-        Yaml y = new Yaml(yamlOptions);
-
-        //FileTK.writeFile(new Yaml().dump(cmdQueue),"T:\\wpc\\00_meta\\debug_.yaml");
-
-        //FileTK.writeFile(new Yaml().dump(cmdQueue),"T:\\wpc\\00_meta\\debug_.yaml");
-        final int length = cmdQueue.size();
-        cmdQueue.forEach(x -> 
-        {
-            Tools.runCmdWithPassthru(null, x);
-            System.out.println("\rVerarbeitet: "+(++pos)+"/"+length);
-        });
-        System.out.println("\nFertigstellen....");
-
-        
-        pos=0;
-        try
-        {
-            LinkedHashMap<String,Object> data = (LinkedHashMap<String,Object>) y.load(new FileInputStream(path+"\\00_meta\\state.yml"));
-            String targetDir = (String) data.get("Outdir");
-            resultFiles.forEach(entry -> 
-            {
-                String fn = FileTK.getFileName(entry);
-                FileTK.kopierpaste(new File(entry),new File(targetDir+"\\"+fn));
-                pos++;
-                if(pos%100==0)
-                {
-                    System.out.print(pos+" Dateien kopiert");
-                }
-                
-            });
-            System.out.print(pos+" Dateien kopiert");
-            System.out.println("\nFertig....");
-            data.put("HEAD", packagesInitialized);
-            String o = y.dump(data);
-            FileTK.writeFile(o, path+"\\00_meta\\state.yml");
-        }
-         
-        catch (FileNotFoundException ex)
-        {
-            ex.printStackTrace();
-        }
-        System.exit(0);
-    }
-    
-    private static int pos;
-    public static void updatePipeLine(String path,String res)
-    {
-        DumperOptions yamlOptions = new DumperOptions();
-        yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
-        Yaml y = new Yaml(yamlOptions);
-        LinkedHashMap<String,Object> data = null;
-        try
-        {
-            data = (LinkedHashMap<String,Object>) y.load(new FileInputStream(path+"\\00_meta\\state.yml"));
-        }
-        catch(IOException lm)
-        {
-        }
-        if(data==null)
-        {
-            return;
-        }
-        String[] dirsExist = FileTK.getDirectoryContent(/*args[0]*/path,true);
-        List<String[]> cmdQueue = new ArrayList<>();
-        List<String> resultFiles = new ArrayList<>();
-        List<String> packagesInitialized = (List<String>) data.get("HEAD");
-        Arrays.stream(dirsExist).filter(t -> !t.startsWith("00_") && new File(path+"\\" + t).isDirectory()).forEach(t ->
-        {
-            if(!packagesInitialized.contains(t)&&FileTK.getDirectoryContent(path+"\\" + t+"\\proc").length>0) //package initialisiert sich erst wenn mindestens ein WP in proc
-            {
-                packagesInitialized.add(t);                           //vv-- highest IDX of package list aka current -> results in counter continuity
-                Object[] rv = processPackage(/*args[0]+*/path+"\\" + t, packagesInitialized.size()-1, res);
-                cmdQueue.addAll((List<String[]>) rv[0]);
-                resultFiles.addAll((List<String>) rv[1]);
-            }
-        });
-        
-
-        //FileTK.writeFile(new Yaml().dump(cmdQueue),"T:\\wpc\\00_meta\\debug_.yaml");
-        final int length = cmdQueue.size();
-        cmdQueue.forEach(x -> 
-        {
-            Tools.runCmdWithPassthru(null, x);
-            System.out.println("\rVerarbeitet: "+(++pos)+"/"+length);
-        });
-        System.out.println("\nFertigstellen....");
-
-        pos=0;
-        
-        String targetDir = (String) data.get("Outdir");
-        resultFiles.forEach(entry -> 
-        {
-            String fn = FileTK.getFileName(entry);
-            FileTK.kopierpaste(new File(entry),new File(targetDir+"\\"+fn));
-            pos++;
-            if(pos%100==0)
-            {
-                System.out.print(pos+" Dateien kopiert");
-            }
-        });
-
-        data.put("HEAD", packagesInitialized);
-        String o = y.dump(data);
-        FileTK.writeFile(o, path+"\\00_meta\\state.yml");
-        System.out.print(pos+" Dateien kopiert");
-        System.out.println("\nFertig....");
-        System.exit(0);
-        
-    }
-    
-    public static Object[] processPackage(String path,int packID,String res)
-    {
-        /*
-        if(false)
-        {
-            System.out.println(packID+"|"+path);
-            return;
-        }*/
-        System.out.println(path);
-        FileTK.verzeichnisKillen(new File(path+"\\p"));
-        new File(path+"\\p\\b\\").mkdirs();
-        String[] availablePackagesNormal = FileTK.getDirectoryContent(path+"\\proc",true);
-        String[] availablePackagesNoResize = FileTK.getDirectoryContent(path+"\\k-i-p",true);
-        String[] availablePackagesBFrames = FileTK.getDirectoryContent(path+"\\b-frames",true);
-        
-        int c1 = availablePackagesNormal==null?0:availablePackagesNormal.length;
-        int c2 = availablePackagesNoResize==null?0:availablePackagesNoResize.length;
-        //System.out.println(c1+"|"+c2+"||"+(c1+c2));
-        String[][] mergedList = new String[c1+c2][2];
-        for (int i = 0; i < c1 ; i++)
-        {
-            String pth = availablePackagesNormal[i];
-            String dst = "proc";
-
-            String fex = FileTK.getFileExt(pth);
-            if(fex!=null&&fex.equals("loc"))
-            {
-                dst ="src";
-                pth=pth.substring(0, pth.length()-4);
-            }
-            mergedList[i][0] = pth;
-            mergedList[i][1] = dst;
-        }
-        for (int i = 0; i < c2; i++)
-        {
-            String pth = availablePackagesNoResize[i];
-            String dst = "k-i-p";
-
-            String fex = FileTK.getFileExt(pth);
-            if(fex!=null&&fex.equals("loc"))
-            {
-                dst ="src";
-                pth=pth.substring(0, pth.length()-4);
-            }
-            mergedList[i+c1][0] = pth;
-            mergedList[i+c1][1] = dst;
-        }
-                            //main inited_b's b_loop
-        int[] cntr = new int[]{0,0,0};//HAX
-        //Arrays.sort(mergedList, ); //verwursteln....
-        List<String[]> commandQueue = new ArrayList<>();
-        List<String> resultFiles = new ArrayList<>();
-        Arrays.stream(mergedList).sorted((x, y) ->
-        {
-            return x[0].compareToIgnoreCase(y[0]);
-        }).forEach((x) ->
-        {
-            String outFile = path + "\\p\\" + String.format("%04d", packID) + "_" + String.format("%04d", cntr[0]++);
-
-            String[] y = x[1].equals("proc")
-                    ? new String[]
-                    {
-                        "C:\\Program Files\\ImageMagick-6.8.8-Q16\\convert.exe", path + "\\" + x[1] + "\\" + x[0], "-resize", res + "!", outFile + ".jpg"
-                    }
-                    : new String[]
-                    {
-                        "C:\\Program Files\\ImageMagick-6.8.8-Q16\\convert.exe", path + "\\" + x[1] + "\\" + x[0], "-resize", res + ">", "-background", "black", "-gravity", "center", "-extent",res, outFile + ".jpg"
-                    };
-            resultFiles.add(outFile+ ".jpg");
-
-            //System.out.println(Arrays.toString(y));
-            if (cntr[0] % 5 == 0)
-            {
-                if (cntr[1] < availablePackagesBFrames.length)
-                {
-                    String bp = path+"\\p\\b\\"+cntr[1]+".jpg";
-                    String dst = "b-frames";
-                    String pth = availablePackagesBFrames[cntr[1]];
-                    String fex = FileTK.getFileExt(pth);
-                    if(fex!=null&fex.equals("loc"))
-                    {
-                        dst="src";
-                        pth=pth.substring(0, pth.length()-4);
-                    }
-                    commandQueue.add(new String[]
-                    {
-                        "C:\\Program Files\\ImageMagick-6.8.8-Q16\\convert.exe", path + "\\"+dst+"\\" + pth, "-resize", res + "!", bp
-                    });
-                    availablePackagesBFrames[cntr[1]]=bp;
-                    cntr[1]++;
-                }
-                commandQueue.add(new String[]{"cmd.exe","/c","copy",availablePackagesBFrames[cntr[2]],outFile+"b.jpg"});
-                cntr[2]=((cntr[2]+1)%availablePackagesBFrames.length);
-                resultFiles.add(outFile+ "b.jpg");
-            }
-            commandQueue.add(y);
-            
-        }
-        ); //System.out.println(packID+"|"+x[0])
-        
-        
-        //DBG FileTK.writeFile(new Yaml().dump(commandQueue),"T:\\wpc\\00_meta\\debug_"+packID+".yaml");
-        //normal
-        //convert in.image -resize res! out.image
-        
-        //keepaspect's
-        // res+">"
-        
-        
-        //convert in.image -resize res+">" -background black -gravity center -extent res out.image
-        return new Object[]{commandQueue,resultFiles};
-    }
-    
-    private static void folderOptimize(String basepath)
-    {
-        String[] dirsExist = FileTK.getDirectoryContent(/*args[0]*/basepath,true);
-        
-        Arrays.stream(dirsExist).filter(t -> !t.startsWith("00_") && new File(basepath+"\\" + t).isDirectory()).forEach(t ->
-        {
-            
-            System.out.println("Optimieren: Verzeichnis "+t+"(@"+pos+")");
-            String path = basepath+"\\" + t;
-            FileTK.verzeichnisKillen(new File(path+"\\p"));
-            
-            List<String> availablePackagesNormal = Arrays.asList(FileTK.getDirectoryContent(path+"\\proc",true));
-            List<String> availablePackagesNoResize = Arrays.asList(FileTK.getDirectoryContent(path+"\\k-i-p",true));
-            List<String> availablePackagesBFrames = Arrays.asList(FileTK.getDirectoryContent(path+"\\b-frames",true));
-            
-            String[] sourceFiles = FileTK.getDirectoryContent(path+"\\src",true);
-            
-            for (String sourceFile : sourceFiles)
-            {
-
-                String fex = FileTK.getFileExt(sourceFile);
-                if(fex!=null&&fex.equals("loc"))
-                {
-                    continue;
-                }
-                String fp = path+"\\src\\"+sourceFile;
-                File src = new File(fp);
-                if(!src.isFile())
-                {
-                    continue;
-                }
-                long fs = src.length();
-                if(availablePackagesNormal.contains(sourceFile))
-                {
-                    String tfp = path+"\\proc\\"+sourceFile;
-                    File cp = new File(tfp);
-                    if(cp.exists()&&(!cp.isDirectory())&&cp.length()==fs)
-                    {
-                        //System.out.println("DELETE "+tfp);
-                        cp.delete();
-                        //System.out.println("CREATE "+tfp+".loc");
-                        try
-                        {
-                            new File(tfp+".loc").createNewFile();
-                        }
-                        catch (IOException ex)
-                        {
-                            ex.printStackTrace();
-                        }/**/
-                        
-                    }  
-                }
-                if(availablePackagesNoResize.contains(sourceFile))
-                {
-                    String tfp = path+"\\k-i-p\\"+sourceFile;
-                    File cp = new File(tfp);
-                    if(cp.exists()&&(!cp.isDirectory())&&cp.length()==fs)
-                    {
-                        //System.out.println("DELETE "+tfp);
-                        cp.delete();
-                        //System.out.println("CREATE "+tfp+".loc");
-                        try
-                        {
-                            new File(tfp+".loc").createNewFile();
-                        }
-                        catch (IOException ex)
-                        {
-                            ex.printStackTrace();
-                        }/**/
-                        
-                    }  
-                }
-                if(availablePackagesBFrames.contains(sourceFile))
-                {
-                    String tfp = path+"\\b-frames\\"+sourceFile;
-                    File cp = new File(tfp);
-                    if(cp.exists()&&(!cp.isDirectory())&&cp.length()==fs)
-                    {
-                        //System.out.println("DELETE "+tfp);
-                        cp.delete();
-                        //System.out.println("CREATE "+tfp+".loc");
-                        try
-                        {
-                            new File(tfp+".loc").createNewFile();
-                        }
-                        catch (IOException ex)
-                        {
-                            ex.printStackTrace();
-                        }/**/
-                        
-                    }  
-                }
-            }
-            
-        });
-    }
-    
-    
-}
+/*
+ * Copyright (C) 2015 iZc
+ *
+ * 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.nplusc.izc.Utilities.WPCMgr;
+
+import de.nplusc.izc.tools.IOtools.FileTK;
+import de.nplusc.izc.tools.baseTools.Tools;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedHashMap;
+import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.Yaml;
+
+/**
+ *
+ * @author LH
+ */
+public class Synchronizer
+{
+    private static final Logger l = LogManager.getLogger();
+    public static void main(String cachedir) throws FileNotFoundException
+    {
+        //DEBUG
+        //path="T:\\wpc";
+        //res="1920x1080";
+        LinkedHashMap<String,Object> data = (LinkedHashMap<String,Object>) WPCUtils.getConfig(cachedir);
+        //calculate screen coverages
+        //2x16:9 allowed in 3x4:3
+        
+        //structure
+        //screenratio>screencount>[screenbase_coord[x,y],virtualsize[x,y]];
+        
+        int[][] screenratios={{16,9},{21,9},{16,10},{4,3}/*,{5,4}*/};
+        
+        int[][] dualratios={{32,9},{42,9},{32,10},{8,3}};
+                                                           
+        int[][] tripleratios = {{48,9},{63,9},{48,10},{12,3}};
+        
+        //install hack for using certain ratio multiscreen WPs in other multiscreen ratios
+        //int[][] tri
+        
+        
+        
+        
+        folderOptimize(cachedir);
+        
+        
+        
+        
+        
+        
+        folderOptimize(cachedir);
+        /*
+        try
+        {
+            
+            LinkedHashMap<String,Object>) new Yaml().load(new FileInputStream(path+"\\00_meta\\state.yml"));
+            if(data.get("HEAD")==null)
+            {
+                initPipeLine(path, res);
+            }
+            else
+            {
+                updatePipeLine(path, res);
+            }
+        }
+        catch (FileNotFoundException ex)
+        {
+            ex.printStackTrace();
+        }*/
+        
+    }
+    
+    public static void initPipeLine(String path,String res)
+    {
+        String[] dirsExist = FileTK.getDirectoryContent(/*args[0]*/path,true);
+        final int pid[] = new int[]{0};
+        List<String[]> cmdQueue = new ArrayList<>();
+        List<String> resultFiles = new ArrayList<>();
+        List<String> packagesInitialized = new ArrayList<>();
+        Arrays.stream(dirsExist).filter(t -> !t.startsWith("00_") && new File(path+"\\" + t).isDirectory()).forEach(t ->
+        {
+            packagesInitialized.add(t);
+            Object[] rv = processPackage(/*args[0]+*/path+"\\" + t, pid[0]++, res);
+            cmdQueue.addAll((List<String[]>) rv[0]);
+            resultFiles.addAll((List<String>) rv[1]);
+        });
+        DumperOptions yamlOptions = new DumperOptions();
+        yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
+        Yaml y = new Yaml(yamlOptions);
+
+        //FileTK.writeFile(new Yaml().dump(cmdQueue),"T:\\wpc\\00_meta\\debug_.yaml");
+
+        //FileTK.writeFile(new Yaml().dump(cmdQueue),"T:\\wpc\\00_meta\\debug_.yaml");
+        final int length = cmdQueue.size();
+        cmdQueue.forEach(x -> 
+        {
+            Tools.runCmdWithPassthru(null, x);
+            System.out.println("\rVerarbeitet: "+(++pos)+"/"+length);
+        });
+        System.out.println("\nFertigstellen....");
+
+        
+        pos=0;
+        try
+        {
+            LinkedHashMap<String,Object> data = (LinkedHashMap<String,Object>) y.load(new FileInputStream(path+"\\00_meta\\state.yml"));
+            String targetDir = (String) data.get("Outdir");
+            resultFiles.forEach(entry -> 
+            {
+                String fn = FileTK.getFileName(entry);
+                FileTK.kopierpaste(new File(entry),new File(targetDir+"\\"+fn));
+                pos++;
+                if(pos%100==0)
+                {
+                    System.out.print(pos+" Dateien kopiert");
+                }
+                
+            });
+            System.out.print(pos+" Dateien kopiert");
+            System.out.println("\nFertig....");
+            data.put("HEAD", packagesInitialized);
+            String o = y.dump(data);
+            FileTK.writeFile(o, path+"\\00_meta\\state.yml");
+        }
+         
+        catch (FileNotFoundException ex)
+        {
+            ex.printStackTrace();
+        }
+        System.exit(0);
+    }
+    
+    private static int pos;
+    public static void updatePipeLine(String path,String res)
+    {
+        DumperOptions yamlOptions = new DumperOptions();
+        yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
+        Yaml y = new Yaml(yamlOptions);
+        LinkedHashMap<String,Object> data = null;
+        try
+        {
+            data = (LinkedHashMap<String,Object>) y.load(new FileInputStream(path+"\\00_meta\\state.yml"));
+        }
+        catch(IOException lm)
+        {
+        }
+        if(data==null)
+        {
+            return;
+        }
+        String[] dirsExist = FileTK.getDirectoryContent(/*args[0]*/path,true);
+        List<String[]> cmdQueue = new ArrayList<>();
+        List<String> resultFiles = new ArrayList<>();
+        List<String> packagesInitialized = (List<String>) data.get("HEAD");
+        Arrays.stream(dirsExist).filter(t -> !t.startsWith("00_") && new File(path+"\\" + t).isDirectory()).forEach(t ->
+        {
+            if(!packagesInitialized.contains(t)&&FileTK.getDirectoryContent(path+"\\" + t+"\\proc").length>0) //package initialisiert sich erst wenn mindestens ein WP in proc
+            {
+                packagesInitialized.add(t);                           //vv-- highest IDX of package list aka current -> results in counter continuity
+                Object[] rv = processPackage(/*args[0]+*/path+"\\" + t, packagesInitialized.size()-1, res);
+                cmdQueue.addAll((List<String[]>) rv[0]);
+                resultFiles.addAll((List<String>) rv[1]);
+            }
+        });
+        
+
+        //FileTK.writeFile(new Yaml().dump(cmdQueue),"T:\\wpc\\00_meta\\debug_.yaml");
+        final int length = cmdQueue.size();
+        cmdQueue.forEach(x -> 
+        {
+            Tools.runCmdWithPassthru(null, x);
+            System.out.println("\rVerarbeitet: "+(++pos)+"/"+length);
+        });
+        System.out.println("\nFertigstellen....");
+
+        pos=0;
+        
+        String targetDir = (String) data.get("Outdir");
+        resultFiles.forEach(entry -> 
+        {
+            String fn = FileTK.getFileName(entry);
+            FileTK.kopierpaste(new File(entry),new File(targetDir+"\\"+fn));
+            pos++;
+            if(pos%100==0)
+            {
+                System.out.print(pos+" Dateien kopiert");
+            }
+        });
+
+        data.put("HEAD", packagesInitialized);
+        String o = y.dump(data);
+        FileTK.writeFile(o, path+"\\00_meta\\state.yml");
+        System.out.print(pos+" Dateien kopiert");
+        System.out.println("\nFertig....");
+        System.exit(0);
+        
+    }
+    
+    public static Object[] processPackage(String path,int packID,String res)
+    {
+        /*
+        if(false)
+        {
+            System.out.println(packID+"|"+path);
+            return;
+        }*/
+        System.out.println(path);
+        FileTK.verzeichnisKillen(new File(path+"\\p"));
+        new File(path+"\\p\\b\\").mkdirs();
+        String[] availablePackagesNormal = FileTK.getDirectoryContent(path+"\\proc",true);
+        String[] availablePackagesNoResize = FileTK.getDirectoryContent(path+"\\k-i-p",true);
+        String[] availablePackagesBFrames = FileTK.getDirectoryContent(path+"\\b-frames",true);
+        
+        int c1 = availablePackagesNormal==null?0:availablePackagesNormal.length;
+        int c2 = availablePackagesNoResize==null?0:availablePackagesNoResize.length;
+        //System.out.println(c1+"|"+c2+"||"+(c1+c2));
+        String[][] mergedList = new String[c1+c2][2];
+        for (int i = 0; i < c1 ; i++)
+        {
+            String pth = availablePackagesNormal[i];
+            String dst = "proc";
+
+            String fex = FileTK.getFileExt(pth);
+            if(fex!=null&&fex.equals("loc"))
+            {
+                dst ="src";
+                pth=pth.substring(0, pth.length()-4);
+            }
+            mergedList[i][0] = pth;
+            mergedList[i][1] = dst;
+        }
+        for (int i = 0; i < c2; i++)
+        {
+            String pth = availablePackagesNoResize[i];
+            String dst = "k-i-p";
+
+            String fex = FileTK.getFileExt(pth);
+            if(fex!=null&&fex.equals("loc"))
+            {
+                dst ="src";
+                pth=pth.substring(0, pth.length()-4);
+            }
+            mergedList[i+c1][0] = pth;
+            mergedList[i+c1][1] = dst;
+        }
+                            //main inited_b's b_loop
+        int[] cntr = new int[]{0,0,0};//HAX
+        //Arrays.sort(mergedList, ); //verwursteln....
+        List<String[]> commandQueue = new ArrayList<>();
+        List<String> resultFiles = new ArrayList<>();
+        Arrays.stream(mergedList).sorted((x, y) ->
+        {
+            return x[0].compareToIgnoreCase(y[0]);
+        }).forEach((x) ->
+        {
+            String outFile = path + "\\p\\" + String.format("%04d", packID) + "_" + String.format("%04d", cntr[0]++);
+
+            String[] y = x[1].equals("proc")
+                    ? new String[]
+                    {
+                        "C:\\Program Files\\ImageMagick-6.8.8-Q16\\convert.exe", path + "\\" + x[1] + "\\" + x[0], "-resize", res + "!", outFile + ".jpg"
+                    }
+                    : new String[]
+                    {
+                        "C:\\Program Files\\ImageMagick-6.8.8-Q16\\convert.exe", path + "\\" + x[1] + "\\" + x[0], "-resize", res + ">", "-background", "black", "-gravity", "center", "-extent",res, outFile + ".jpg"
+                    };
+            resultFiles.add(outFile+ ".jpg");
+
+            //System.out.println(Arrays.toString(y));
+            if (cntr[0] % 5 == 0)
+            {
+                if (cntr[1] < availablePackagesBFrames.length)
+                {
+                    String bp = path+"\\p\\b\\"+cntr[1]+".jpg";
+                    String dst = "b-frames";
+                    String pth = availablePackagesBFrames[cntr[1]];
+                    String fex = FileTK.getFileExt(pth);
+                    if(fex!=null&fex.equals("loc"))
+                    {
+                        dst="src";
+                        pth=pth.substring(0, pth.length()-4);
+                    }
+                    commandQueue.add(new String[]
+                    {
+                        "C:\\Program Files\\ImageMagick-6.8.8-Q16\\convert.exe", path + "\\"+dst+"\\" + pth, "-resize", res + "!", bp
+                    });
+                    availablePackagesBFrames[cntr[1]]=bp;
+                    cntr[1]++;
+                }
+                commandQueue.add(new String[]{"cmd.exe","/c","copy",availablePackagesBFrames[cntr[2]],outFile+"b.jpg"});
+                cntr[2]=((cntr[2]+1)%availablePackagesBFrames.length);
+                resultFiles.add(outFile+ "b.jpg");
+            }
+            commandQueue.add(y);
+            
+        }
+        ); //System.out.println(packID+"|"+x[0])
+        
+        
+        //DBG FileTK.writeFile(new Yaml().dump(commandQueue),"T:\\wpc\\00_meta\\debug_"+packID+".yaml");
+        //normal
+        //convert in.image -resize res! out.image
+        
+        //keepaspect's
+        // res+">"
+        
+        
+        //convert in.image -resize res+">" -background black -gravity center -extent res out.image
+        return new Object[]{commandQueue,resultFiles};
+    }
+    
+    private static void folderOptimize(String basepath)
+    {
+        String[] dirsExist = FileTK.getDirectoryContent(/*args[0]*/basepath,true);
+        
+        Arrays.stream(dirsExist).filter(t -> !t.startsWith("00_") && new File(basepath+"\\" + t).isDirectory()).forEach(t ->
+        {
+            
+            System.out.println("Optimieren: Verzeichnis "+t+"(@"+pos+")");
+            String path = basepath+"\\" + t;
+            FileTK.verzeichnisKillen(new File(path+"\\p"));
+            
+            List<String> availablePackagesNormal = Arrays.asList(FileTK.getDirectoryContent(path+"\\proc",true));
+            List<String> availablePackagesNoResize = Arrays.asList(FileTK.getDirectoryContent(path+"\\k-i-p",true));
+            List<String> availablePackagesBFrames = Arrays.asList(FileTK.getDirectoryContent(path+"\\b-frames",true));
+            
+            String[] sourceFiles = FileTK.getDirectoryContent(path+"\\src",true);
+            
+            for (String sourceFile : sourceFiles)
+            {
+
+                String fex = FileTK.getFileExt(sourceFile);
+                if(fex!=null&&fex.equals("loc"))
+                {
+                    continue;
+                }
+                String fp = path+"\\src\\"+sourceFile;
+                File src = new File(fp);
+                if(!src.isFile())
+                {
+                    continue;
+                }
+                long fs = src.length();
+                if(availablePackagesNormal.contains(sourceFile))
+                {
+                    String tfp = path+"\\proc\\"+sourceFile;
+                    File cp = new File(tfp);
+                    if(cp.exists()&&(!cp.isDirectory())&&cp.length()==fs)
+                    {
+                        //System.out.println("DELETE "+tfp);
+                        cp.delete();
+                        //System.out.println("CREATE "+tfp+".loc");
+                        try
+                        {
+                            new File(tfp+".loc").createNewFile();
+                        }
+                        catch (IOException ex)
+                        {
+                            ex.printStackTrace();
+                        }/**/
+                        
+                    }  
+                }
+                if(availablePackagesNoResize.contains(sourceFile))
+                {
+                    String tfp = path+"\\k-i-p\\"+sourceFile;
+                    File cp = new File(tfp);
+                    if(cp.exists()&&(!cp.isDirectory())&&cp.length()==fs)
+                    {
+                        //System.out.println("DELETE "+tfp);
+                        cp.delete();
+                        //System.out.println("CREATE "+tfp+".loc");
+                        try
+                        {
+                            new File(tfp+".loc").createNewFile();
+                        }
+                        catch (IOException ex)
+                        {
+                            ex.printStackTrace();
+                        }/**/
+                        
+                    }  
+                }
+                if(availablePackagesBFrames.contains(sourceFile))
+                {
+                    String tfp = path+"\\b-frames\\"+sourceFile;
+                    File cp = new File(tfp);
+                    if(cp.exists()&&(!cp.isDirectory())&&cp.length()==fs)
+                    {
+                        //System.out.println("DELETE "+tfp);
+                        cp.delete();
+                        //System.out.println("CREATE "+tfp+".loc");
+                        try
+                        {
+                            new File(tfp+".loc").createNewFile();
+                        }
+                        catch (IOException ex)
+                        {
+                            ex.printStackTrace();
+                        }/**/
+                    }  
+                }
+            }
+        });
+    }
+    
+    
+}

+ 110 - 84
WPCMGr/src/main/java/de/nplusc/izc/Utilities/WPCMgr/WPCUtils.java

@@ -1,84 +1,110 @@
-/*
- * Copyright (C) 2015 iZc
- *
- * 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.nplusc.izc.Utilities.WPCMgr;
-
-import de.nplusc.izc.tools.IOtools.FileTK;
-import java.io.File;
-import java.util.LinkedHashMap;
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.Yaml;
-
-/**
- *
- * @author LH
- */
-public class WPCUtils
-{
-    public static void initCache(String dir,String wptargetdir)
-    {
-        String[] dirs = new String[]{
-            "00_meta",
-            "00_template\\archv_srcs",
-            "00_template\\b-frames",
-            "00_template\\k-i-p",
-            "00_template\\p",
-            "00_template\\proc",
-            "00_template\\src",
-        };
-        for (String string : dirs)
-        {
-            //Scheiss gänsefüßchen haben richtiig zu sitzen
-            new File(dir+"\\"+string).mkdirs();
-        }
-        FileTK.writeFile(getInitialMetaState(wptargetdir), dir+"\\00_meta\\state.yml");
-        if(!new File(dir+"\\readme.txt").exists())
-        {
-        FileTK.writeFile("Die Struktur ab L10 ist wie folgt:\n" +
-                        "\n" +
-                        "-+    / Wirzelverzeichnis des Packages\n" +
-                        " +- archv_srcs Wenn Daten in ner Zip kamen diese hier einlagern\n" +
-                        " +- b-frames die wiederkehrenden Bilder des Packages (min 1 nötig)\n" +
-                        " +- k-i-p bilder die proportional bleiben müssen\n" +
-                        " +- p Bilder die verarbeitet wirden (bereits nummeriert)\n" +
-                        " +- proc unverarbeitete bilder die unproportional skaliert werden können\n" +
-                        " +- src unsortiertes Rohmaterial //kann auch in / liegen\n" +
-                        " \n" +
-                        " \n" +
-                        " 00_-verzeichnisse sind Meta-verzeichnisse ohne Pixelinhalt", dir+"\\readme.txt");
-        }
-    }
-
-    
-    public static String getInitialMetaState(String wptargetDir)
-    {
-        DumperOptions yamlOptions = new DumperOptions();
-        yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
-        LinkedHashMap<String,Object> m = new LinkedHashMap<>();
-        m.put("HEAD",null);//null heißt frisch
-        m.put("Outdir",wptargetDir);
-        return new Yaml(yamlOptions).dump(m);
-    }
-    
-    public static void main(String[] args)
-    {
-        //FileTK.writeFile(getInitialMetaState(), "T:\\wpc\\00_meta\\state.yml");
-    }
-    
-    private WPCUtils()
-    {
-    }
-}
+/*
+ * Copyright (C) 2015 iZc
+ *
+ * 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.nplusc.izc.Utilities.WPCMgr;
+
+import de.nplusc.izc.tools.IOtools.FileTK;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.Yaml;
+
+/**
+ *
+ * @author LH
+ */
+public class WPCUtils
+{
+    public static void initCache(String dir,String wptargetdir)
+    {
+        String[] dirs = new String[]{
+            "00_meta",
+            "00_template\\archv_srcs",
+            "00_template\\b-frames",
+            "00_template\\k-i-p",
+            "00_template\\p",
+            "00_template\\proc",
+            "00_template\\src",
+        };
+        for (String string : dirs)
+        {
+            //Scheiss gänsefüßchen haben richtiig zu sitzen
+            new File(dir+"\\"+string).mkdirs();
+        }
+        FileTK.writeFile(getInitialMetaState(wptargetdir), dir+"\\00_meta\\state.yml");
+        if(!new File(dir+"\\readme.txt").exists())
+        {
+        FileTK.writeFile("Die Struktur ab L10 ist wie folgt:\n" +
+                        "\n" +
+                        "-+    / Wirzelverzeichnis des Packages\n" +
+                        " +- archv_srcs Wenn Daten in ner Zip kamen diese hier einlagern\n" +
+                        " +- b-frames die wiederkehrenden Bilder des Packages (min 1 nötig)\n" +
+                        " +- k-i-p bilder die proportional bleiben müssen\n" +
+                        " +- p Bilder die verarbeitet wirden (bereits nummeriert)\n" +
+                        " +- proc unverarbeitete bilder die unproportional skaliert werden können\n" +
+                        " +- src unsortiertes Rohmaterial //kann auch in / liegen\n" +
+                        " \n" +
+                        " \n" +
+                        " 00_-verzeichnisse sind Meta-verzeichnisse ohne Pixelinhalt", dir+"\\readme.txt");
+        }
+    }
+
+    
+    public static String getInitialMetaState(String wptargetDir)
+    {
+        DumperOptions yamlOptions = new DumperOptions();
+        yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
+        LinkedHashMap<String,Object> m = new LinkedHashMap<>();
+        m.put("HEAD",null);//null heißt frisch
+        m.put("Outdir",wptargetDir);
+        return new Yaml(yamlOptions).dump(m);
+    }
+    
+    public static void main(String[] args)
+    {
+        //FileTK.writeFile(getInitialMetaState(), "T:\\wpc\\00_meta\\state.yml");
+    }
+    
+    public static HashMap<String,Object> getConfig(String folder) throws FileNotFoundException
+    {
+        return (LinkedHashMap<String,Object>) new Yaml().load(new FileInputStream(folder+"\\00_meta\\state.yml"));
+    }
+    private WPCUtils()
+    {
+    }
+    @SuppressWarnings("Convert2Diamond") //required, otherwise compiler thinks its too clever
+    public static void addMonitor(HashMap<String,Object> config,String ID,int x,int y,int w,int h)
+    {
+        if(!config.containsKey("MONITORS"))
+        {
+            config.put("MONITORS", new LinkedHashMap<String, int[]>());
+        }
+        LinkedHashMap<String,int[]> data = (LinkedHashMap<String,int[]>) config.get("MONITORS");
+        data.put(ID,new int[]{x,y,w,h});
+    }
+    
+    public static void saveConfig(String folder,HashMap<String,Object> config)
+    {
+        DumperOptions yamlOptions = new DumperOptions();
+        yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
+        LinkedHashMap<String,Object> m = new LinkedHashMap<>();
+        String o = new Yaml(yamlOptions).dump(config);
+        FileTK.writeFile(o, folder+"\\00_meta\\state.yml");
+    }
+}

+ 40 - 0
WPCMGr/src/main/resources/log4j2.xml

@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration status="WARN">
+    <Appenders>
+        <Console name="Console" target="SYSTEM_OUT">
+            <PatternLayout pattern="%highlight{%d{HH:mm:ss.SSS} [%t] %-5level %l - %msg%n}{FATAL=red, ERROR=red, WARN=yellow, INFO=green, DEBUG=blue, TRACE=blue}"/>
+        </Console>
+        
+        <Console name="ConsoleExternal" target="SYSTEM_OUT">
+            <PatternLayout pattern="%highlight{%d{HH:mm:ss.SSS} [[%logger]] %-5level - %msg%n}{FATAL=red, ERROR=red, WARN=yellow, INFO=green, DEBUG=blue, TRACE=blue}"/>
+        </Console>
+        
+        
+        <RollingFile name="logfile" fileName="izpl.log" filePattern="izpl-%i.log">
+        <Policies>
+            <OnStartupTriggeringPolicy />
+            </Policies>
+            <DefaultRolloverStrategy min="1" max="1"/>
+            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %l - %msg%n"/>
+        </RollingFile>   
+
+        <RollingFile name="logfileExternal" fileName="izpl.log" filePattern="izpl-%i.log">
+        <Policies>
+            <OnStartupTriggeringPolicy />
+            </Policies>
+            <DefaultRolloverStrategy min="1" max="1"/>
+            <PatternLayout pattern="%d{HH:mm:ss.SSS} [[%logger]] %-5level - %msg%n"/>
+        </RollingFile>   
+        
+    </Appenders>
+    <Loggers>
+    <Root level="info">
+        <AppenderRef ref="Console"/>
+        <AppenderRef ref="logfile"/>
+    </Root>
+    <Logger name="External" level="info" additivity="false">
+        <AppenderRef ref="ConsoleExternal"/>
+        <AppenderRef ref="logfileExternal"/>
+    </Logger>
+    </Loggers>
+</Configuration>

+ 40 - 0
WPCMGr/src/main/resources/log4j2NonVerbose.xml

@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration status="WARN">
+    <Appenders>
+        <Console name="Console" target="SYSTEM_OUT">
+            <PatternLayout pattern="%highlight{%d{HH:mm:ss.SSS} [%t] %-5level &gt; %msg%n}{FATAL=red, ERROR=red, WARN=yellow, INFO=green, DEBUG=black, TRACE=blue}"/>
+        </Console>
+        
+        <Console name="ConsoleExternal" target="SYSTEM_OUT">
+            <PatternLayout pattern="%highlight{%d{HH:mm:ss.SSS} [[%logger]] %-5level &gt; %msg%n}{FATAL=red, ERROR=red, WARN=yellow, INFO=green, DEBUG=black, TRACE=blue}"/>
+        </Console>
+        
+        
+        <RollingFile name="logfile" fileName="izpl.log" filePattern="izpl-%i.log">
+        <Policies>
+            <OnStartupTriggeringPolicy />
+            </Policies>
+            <DefaultRolloverStrategy max="0"/>
+            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %l - %msg%n"/>
+        </RollingFile>   
+
+        <RollingFile name="logfileExternal" fileName="izpl.log" filePattern="izpl-%i.log">
+        <Policies>
+            <OnStartupTriggeringPolicy />
+            </Policies>
+            <DefaultRolloverStrategy max="0"/>
+            <PatternLayout pattern="%d{HH:mm:ss.SSS} [[%logger]] %-5level - %msg%n"/>
+        </RollingFile>   
+        
+    </Appenders>
+    <Loggers>
+    <Root level="info">
+        <AppenderRef ref="Console"/>
+        <AppenderRef ref="logfile"/>
+    </Root>
+    <Logger name="External" level="info" additivity="false">
+        <AppenderRef ref="ConsoleExternal"/>
+        <AppenderRef ref="logfileExternal"/>
+    </Logger>
+    </Loggers>
+</Configuration>

+ 461 - 454
izpl-shared/src/main/java/de/nplusc/izc/iZpl/Utils/shared/PLFileIO.java

@@ -1,454 +1,461 @@
-/*
- * Copyright (C) 2015 iZc
- *
- * 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.nplusc.izc.iZpl.Utils.shared;
-
-import de.nplusc.izc.iZpl.API.shared.InvalidPlayListFileException;
-import de.nplusc.izc.iZpl.API.shared.MultiPlayListItem;
-import de.nplusc.izc.iZpl.API.shared.PlayListFile;
-import de.nplusc.izc.iZpl.API.shared.PlayListItem;
-import de.nplusc.izc.iZpl.API.shared.RawPlayListFile;
-import de.nplusc.izc.iZpl.API.shared.SinglePlayListItem;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-/**
- *
- * @author iZc <nplusc.de>
- */
-public class PLFileIO
-{
-    //Formatdefinition //basiert aufne verpackte #extm3u
-    /*
-    * #EXTM3U
-    * #IZPL
-    * #IZPH:Fieldname|value
-    * #EXTINFO.......//Die VLC-Daten
-    * #IZPL:PrioMultiplier|GroupID (IDS !=0 sind Verbunden. 0er immer einzeln)
-    * /Pfad/zu/File1.mp3
-    * //Defaultet zu 1,0 falls nicht gefunden
-    * #IZPL:INCLUDE|PrioMultiplier|Expand//INCLUDE sagt dass hier ne referenzierte IZPL liegt Expand sagt Liste kann aufgeteilt werden
-    * /Pfad/zu/andererListe.iZpl //prioMultiplier bei include mutipliziert Multiopliers des Includes
-    * #IZPL:INCLUDE|PrioMultiplier|NoExpand //NoExpand sagt dass File Als ein Block behandelt werden muss (Includes innerhalb werden auch beachtet aber keine multiplizierungen eingebaut
-    * /Pfad/zu/UnsplittbarerListe.iZpl
-    */
-    
-    
-    //private static Yaml y = new Yaml();
-    private static final Logger l = LogManager.getLogger();
-    public static RawPlayListFile readSingleList(String path) throws InvalidPlayListFileException
-    {
-        String plbd = new File(path).getParent()+File.separator;
-        l.trace("Location:{}",new File(path).getAbsolutePath());
-        try
-        {
-            String rootDir="";
-            boolean syntaxError=false;
-            FileReader fra = new FileReader(path);
-            BufferedReader fr = new BufferedReader(fra);
-
-            if(!(fr.readLine().equalsIgnoreCase("#EXTM3U")))
-            {
-                //TODO redirect to external lib for converting to iZpl
-                l.error("Not a valid izpl or M3u-file");
-                return new RawPlayListFile("", new ArrayList<SinglePlayListItem>());
-            }
-            String ln = fr.readLine();
-            int lne=3;
-            if(!ln.startsWith("#IZPL"))
-            {
-                l.info("plain M3u detected");
-                lne=2;
-            }
-            else//IZPL header processing
-            {
-                ln=fr.readLine();
-                while(ln!=null&&(ln.startsWith("#IZPH")||ln.trim().equals("")))
-                {
-                    if(!ln.trim().equals(""))
-                    {
-                        String section = ln.split(":")[1];
-                        section=section.toLowerCase();
-                        switch(section)
-                        {
-                            case "basedir":
-                                rootDir=section.substring(section.indexOf("|"));
-                                break;
-                            default:
-                                l.info("Unknown Header field ({}) detected at line: {}",section,lne);
-                                break;
-                        }
-                    }
-                    lne++;
-                }
-            }
- 
-            ArrayList<SinglePlayListItem> returndata = new ArrayList<>();
-            
-            boolean extinf=false;
-            SinglePlayListItem itm = new SinglePlayListItem();
-            boolean encounteredParseableLine=false;
-            ArrayList<String> itmprefix = new ArrayList<>();
-            ArrayList<String> itmsuffix = new ArrayList<>();
-            ArrayList<String> tail = new ArrayList<>();
-            while(ln!=null)
-            {
-                if(!ln.trim().equals(""))
-                {
-                    l.trace(ln);
-                    if(ln.startsWith("#IZPL"))
-                    {
-                        encounteredParseableLine=true;
-                        String[] meta = ln.split(":")[1].split("\\|");
-                        if(meta[0].equalsIgnoreCase("include"))
-                        {
-                            if(meta.length==3)
-                            {
-                                if(meta[2].equalsIgnoreCase("expand"))
-                                {
-                                    itm.setIncludeElements(true, false);
-                                }
-                                else
-                                {
-                                    if(meta[2].equalsIgnoreCase("noexpand"))
-                                    {
-                                         itm.setIncludeElements(true, true);
-                                    }
-                                    else
-                                    {
-                                        syntaxError=true;
-                                        l.error("Syntax error on line {} of file {}: {}",lne,path,"Include-Block haben nur Expand oder NoExpand als dritten block");
-                                        continue;
-                                    }
-                                }
-                                try
-                                {
-                                    int pr = Integer.valueOf(meta[1]);
-                                    if(pr<1)
-                                    {
-                                        throw new NumberFormatException();
-                                    }
-                                    itm.setTargetPlaycount(pr);
-                                }
-                                catch(NumberFormatException x)
-                                {
-                                    syntaxError=true;
-                                    l.error("Syntax error on line {} of file {}: {}",lne,path,"der 2. block bei Include muss eine positive Ganzzahl sein");
-                                    itm.setTargetPlaycount(1);
-                                }
-                            }
-                            else
-                            {
-                                syntaxError=true;
-                                l.error("Syntax error on line {} of file {}: {}",lne,path,"Include-Block braucht 2 weitere blöcke um korrekt zu sein");
-                            }
-                        }
-                        else
-                        {
-                            if(meta.length==2)
-                            {
-                                try
-                                {
-                                    int pr = Integer.valueOf(meta[0]);
-                                    if (pr < 1)
-                                    {
-                                        throw new NumberFormatException();
-                                    }
-                                    itm.setTargetPlaycount(pr);
-                                }
-                                catch (NumberFormatException x)
-                                {
-                                    syntaxError = true;
-                                    l.error("Syntax error on line {} of file {}: {}", lne, path, "Block1 muss eine Ganzzahl > 0 sein");
-                                    itm.setTargetPlaycount(1);
-                                }
-                                try
-                                {
-                                    l.trace(meta[1]);
-                                    int gid = Integer.valueOf(meta[1].trim());
-                                    if (gid < 0)
-                                    {
-                                        l.trace("NULL0");
-                                        throw new NumberFormatException();
-                                    }
-                                    itm.setGID(gid); 
-                                }
-                                catch (NumberFormatException x)
-                                {
-                                    syntaxError = true;
-                                    l.error("Syntax error on line {} of file {}: {}", lne, path, "Block2 muss eine Ganzzahl >=0 sein");
-                                    itm.setGID(0);
-                                }
-                            }
-                            else
-                            {
-                                syntaxError=true;
-                                l.error("Syntax error on line {} of file {}: {}",lne,path,"Could not determine Metadata block type");
-                            }
-                        }
-                    }
-                    else
-                    {
-                        if(ln.startsWith("#EXTINF"))
-                        {
-                            extinf=true;
-                            itm.setTitle(ln);
-                            encounteredParseableLine=true;
-                        }
-                        else
-                        {
-                            if(!ln.startsWith("#"))
-                            {
-                                if(!extinf)
-                                {
-                                    itm.setTitle("#EXTINF,0,"+new File(ln).getName());
-                                }
-                                if(!(ln.substring(1).startsWith(":")||ln.startsWith(File.separator)))
-                                {
-                                    ln=plbd+ln;//relative pfade absolutisieren
-                                }
-                                itm.setPath(ln);
-                                itm.setPrefix(itmprefix.toArray(new String[]{}));
-                                itm.setInlineCOmmentLines(itmprefix.toArray(new String[]{}));
-                                returndata.add(itm);
-                                itm=new SinglePlayListItem();
-                                extinf=false;
-                                itmprefix.clear();
-                                itmsuffix.clear();
-                                tail.clear();
-                            }
-                            else
-                            {
-                                if(encounteredParseableLine)
-                                {
-                                    tail.add(ln);
-                                    itmsuffix.add(ln);
-                                }
-                                else
-                                {
-                                    tail.add(ln);
-                                    itmprefix.add(ln);
-                                }
-                            }
-                        }
-                    }
-                }
-                lne++;
-                ln=fr.readLine();
-            }
-            if(syntaxError)
-            {
-                throw new InvalidPlayListFileException();
-            }
-            fr.close();
-            return new RawPlayListFile(rootDir,returndata,tail.toArray(new String[]{}));
-        }
-        catch (IOException ex)
-        {
-            return new RawPlayListFile("", new ArrayList<SinglePlayListItem>());
-        }
-    }
-    
-    public static List<PlayListItem> parseFullList(String path) throws InvalidPlayListFileException
-    {
-        return parseFullList(path, 40,false);
-        
-    }
-    
-    public static List<PlayListItem> parseFullList(String path,int rd) throws InvalidPlayListFileException
-    {
-        return parseFullList(path, rd,false);
-    }
-    
-    public static List<PlayListItem> parseFullList(String path,int rd,boolean singelifyMultiItems) throws InvalidPlayListFileException
-    {
-        
-    HashMap<Integer,MultiPlayListItem> groups = new HashMap<>();
-    List<PlayListItem> result = new ArrayList<>();
-
-        List<SinglePlayListItem> rootList = readSingleList(path).getData();
-        try{
-            Class yaml = Class.forName("org.yaml.snakeyaml.Yaml");
-            Object y = yaml.getConstructor().newInstance();
-            l.trace(yaml.getMethod("dump", Object.class).invoke(y, rootList));
-        }
-        catch(Exception e)
-        {
-        
-        }
-        for (SinglePlayListItem re : rootList)
-        {
-            if(re.isIncludeElement())
-            {
-                if(re.noexpandoninclude())
-                {
-                    MultiPlayListItem m = processNoExpandInclude(re.getPath(),rd);
-                    if(m!=null)
-                    {
-                        m.setTargetPlaycount(re.getTargetPlaycount());
-                        if(singelifyMultiItems)
-                        {
-                            result.addAll(Arrays.asList(m.getSinglePlayListElements()));
-                        }
-                        else
-                        {
-                            result.add(m);
-                        }
-                    }
-                }
-                else
-                {
-                    List<PlayListItem> temp = parseFullList(re.getPath(),rd-1);
-                    for (PlayListItem ple : temp)
-                    {
-                        ple.setTargetPlaycount(ple.getTargetPlaycount()*re.getTargetPlaycount());
-                    }
-                    result.addAll(temp);
-                }
-            }
-            else
-            {
-                int gid=re.getGID();
-                if(gid==0)
-                {
-                    result.add(re);
-                }
-                else
-                {
-                    if(!groups.containsKey(gid))
-                    {
-                        groups.put(gid,new MultiPlayListItem());
-                    }
-                    MultiPlayListItem gt = groups.get(gid);
-                    gt.addItem(re);
-                }
-            }
-        }
-        return result;
-    }
-    
-    private static MultiPlayListItem processNoExpandInclude(String path,int rd) throws InvalidPlayListFileException
-    {
-        MultiPlayListItem mi = new MultiPlayListItem();
-        if(rd<0)
-        {
-            return null;
-        }
-        rd--;
-        List<SinglePlayListItem> raw = readSingleList(path).getData();
-        for (SinglePlayListItem spi : raw)
-        {
-            if(spi.isIncludeElement())
-            {
-                mi.addItem(processNoExpandInclude(spi.getPath(), rd));
-            }
-            else
-            {
-                mi.addItem(spi);
-            }
-        }
-        return mi;
-    }
-    
-    public static void writePLFile(PlayListFile f)
-    {
-        // Arbeit mit derPath-Klasse & der File.getPath() methode, Reflection dient zur Kompatibilität mitSystemen ohne dieser Klasse (wie Androiden)
-        try{
-            boolean supportinRelativeness=false;
-            Object basepath = null;
-            Class pathclass=null;
-            try
-            {
-                pathclass = Class.forName("java.nio.file.Path");
-                supportinRelativeness=true;
-            }
-            catch(ClassNotFoundException x)
-            {
-                //Nix da wenn der error auftritt nur ein feature deaktiviert wird
-            }
-            Method pfadheraberdalli = File.class.getMethod("toPath");
-            
-            if(supportinRelativeness)
-            {
-                File magix = new File(f.getPath()).getParentFile();
-                basepath =  pfadheraberdalli.invoke(magix);
-            }
-            try
-            {
-                String fp = f.getPath();
-                String pld = "#EXTM3U\n#IZPL\n";
-                for (SinglePlayListItem pli : f.getEntries())
-                {
-                    String pathOfFile = pli.getPath();
-                            
-                    if(supportinRelativeness)
-                    {
-                        Method rel=pathclass.getMethod("relativize", (Class)pathclass);
-                        File current = new File(pathOfFile);
-                        Object pa = pfadheraberdalli.invoke(current);
-                        l.trace("pa-Class:"+pa.getClass());
-                        Object figgdi = rel.invoke(basepath, pa);
-                        l.trace("figgdi-Class:"+figgdi.getClass());
-                        pathOfFile=figgdi+"";
-                    }
-                           // = p.relativize(new File().toPath()).toString();
-
-
-                    if(pli.isIncludeElement())
-                    {
-                        pld+="#IZPL:INCLUDE|"+pli.getTargetPlaycount()+"|"+(pli.noexpandoninclude()?"NOEXPAND":"EXPAND")+"\n"+pathOfFile+"\n";
-                    }
-                    else
-                    {
-                        pld+=pli.getTitle()+"\n"+"#IZPL:"+pli.getTargetPlaycount()+"|"+pli.getGID()+"\n"+pathOfFile+"\n";
-                    }
-                }
-                RandomAccessFile file = new RandomAccessFile(fp, "rw");
-                file.setLength(0);
-                file.write(pld.getBytes());
-                file.close();
-            }
-            catch (IOException ex)
-            {
-                ex.printStackTrace();
-            }
-        }
-        catch(NoSuchMethodException |IllegalAccessException | IllegalArgumentException | InvocationTargetException ex)
-        {
-            ex.printStackTrace();
-        }
-    }
-    
-    
-    
-    private PLFileIO()
-    {
-    }
-    
-    
-}
+/*
+ * Copyright (C) 2015 iZc
+ *
+ * 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.nplusc.izc.iZpl.Utils.shared;
+
+import de.nplusc.izc.iZpl.API.shared.InvalidPlayListFileException;
+import de.nplusc.izc.iZpl.API.shared.MultiPlayListItem;
+import de.nplusc.izc.iZpl.API.shared.PlayListFile;
+import de.nplusc.izc.iZpl.API.shared.PlayListItem;
+import de.nplusc.izc.iZpl.API.shared.RawPlayListFile;
+import de.nplusc.izc.iZpl.API.shared.SinglePlayListItem;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/**
+ *
+ * @author iZc <nplusc.de>
+ */
+public class PLFileIO
+{
+    //Formatdefinition //basiert aufne verpackte #extm3u
+    /*
+    * #EXTM3U
+    * #IZPL
+    * #IZPH:Fieldname|value
+    * #EXTINFO.......//Die VLC-Daten
+    * #IZPL:PrioMultiplier|GroupID (IDS !=0 sind Verbunden. 0er immer einzeln)
+    * /Pfad/zu/File1.mp3
+    * //Defaultet zu 1,0 falls nicht gefunden
+    * #IZPL:INCLUDE|PrioMultiplier|Expand//INCLUDE sagt dass hier ne referenzierte IZPL liegt Expand sagt Liste kann aufgeteilt werden
+    * /Pfad/zu/andererListe.iZpl //prioMultiplier bei include mutipliziert Multiopliers des Includes
+    * #IZPL:INCLUDE|PrioMultiplier|NoExpand //NoExpand sagt dass File Als ein Block behandelt werden muss (Includes innerhalb werden auch beachtet aber keine multiplizierungen eingebaut
+    * /Pfad/zu/UnsplittbarerListe.iZpl
+    */
+    
+    
+    //private static Yaml y = new Yaml();
+    private static final Logger l = LogManager.getLogger();
+    public static RawPlayListFile readSingleList(String path) throws InvalidPlayListFileException
+    {
+        String plbd = new File(path).getParent()+File.separator;
+        l.trace("Location:{}",new File(path).getAbsolutePath());
+        try
+        {
+            String rootDir="";
+            boolean syntaxError=false;
+            FileReader fra = new FileReader(path);
+            BufferedReader fr = new BufferedReader(fra);
+
+            if(!(fr.readLine().equalsIgnoreCase("#EXTM3U")))
+            {
+                //TODO redirect to external lib for converting to iZpl
+                l.error("Not a valid izpl or M3u-file");
+                return new RawPlayListFile("", new ArrayList<SinglePlayListItem>());
+            }
+            String ln = fr.readLine();
+            int lne=3;
+            if(!ln.startsWith("#IZPL"))
+            {
+                l.info("plain M3u detected");
+                lne=2;
+            }
+            else//IZPL header processing
+            {
+                ln=fr.readLine();// falsch!
+                while(ln!=null&&(ln.startsWith("#IZPH")||ln.trim().equals("")))
+                {
+                    if(!ln.trim().equals(""))
+                    {
+                        l.trace("Header Line:{}",ln);
+                        String[] spl = ln.split(":");
+                        if(spl.length<2)
+                        {
+                            continue;
+                        }
+                        String section = spl[1];
+                        section=section.toLowerCase();
+                        switch(section)
+                        {
+                            case "basedir":
+                                rootDir=section.substring(section.indexOf("|"));
+                                break;
+                            default:
+                                l.info("Unknown Header field ({}) detected at line: {}",section,lne);
+                                break;
+                        }
+                    }
+                    lne++;
+                    ln=fr.readLine();//nope, du hast hier unten zu sein, sonst gibts ne fette endlosschleife
+                }
+            }
+ 
+            ArrayList<SinglePlayListItem> returndata = new ArrayList<>();
+            
+            boolean extinf=false;
+            SinglePlayListItem itm = new SinglePlayListItem();
+            boolean encounteredParseableLine=false;
+            ArrayList<String> itmprefix = new ArrayList<>();
+            ArrayList<String> itmsuffix = new ArrayList<>();
+            ArrayList<String> tail = new ArrayList<>();
+            while(ln!=null)
+            {
+                if(!ln.trim().equals(""))
+                {
+                    l.trace(ln);
+                    if(ln.startsWith("#IZPL"))
+                    {
+                        encounteredParseableLine=true;
+                        String[] meta = ln.split(":")[1].split("\\|");
+                        if(meta[0].equalsIgnoreCase("include"))
+                        {
+                            if(meta.length==3)
+                            {
+                                if(meta[2].equalsIgnoreCase("expand"))
+                                {
+                                    itm.setIncludeElements(true, false);
+                                }
+                                else
+                                {
+                                    if(meta[2].equalsIgnoreCase("noexpand"))
+                                    {
+                                         itm.setIncludeElements(true, true);
+                                    }
+                                    else
+                                    {
+                                        syntaxError=true;
+                                        l.error("Syntax error on line {} of file {}: {}",lne,path,"Include-Block haben nur Expand oder NoExpand als dritten block");
+                                        continue;
+                                    }
+                                }
+                                try
+                                {
+                                    int pr = Integer.valueOf(meta[1]);
+                                    if(pr<1)
+                                    {
+                                        throw new NumberFormatException();
+                                    }
+                                    itm.setTargetPlaycount(pr);
+                                }
+                                catch(NumberFormatException x)
+                                {
+                                    syntaxError=true;
+                                    l.error("Syntax error on line {} of file {}: {}",lne,path,"der 2. block bei Include muss eine positive Ganzzahl sein");
+                                    itm.setTargetPlaycount(1);
+                                }
+                            }
+                            else
+                            {
+                                syntaxError=true;
+                                l.error("Syntax error on line {} of file {}: {}",lne,path,"Include-Block braucht 2 weitere blöcke um korrekt zu sein");
+                            }
+                        }
+                        else
+                        {
+                            if(meta.length==2)
+                            {
+                                try
+                                {
+                                    int pr = Integer.valueOf(meta[0]);
+                                    if (pr < 1)
+                                    {
+                                        throw new NumberFormatException();
+                                    }
+                                    itm.setTargetPlaycount(pr);
+                                }
+                                catch (NumberFormatException x)
+                                {
+                                    syntaxError = true;
+                                    l.error("Syntax error on line {} of file {}: {}", lne, path, "Block1 muss eine Ganzzahl > 0 sein");
+                                    itm.setTargetPlaycount(1);
+                                }
+                                try
+                                {
+                                    l.trace(meta[1]);
+                                    int gid = Integer.valueOf(meta[1].trim());
+                                    if (gid < 0)
+                                    {
+                                        l.trace("NULL0");
+                                        throw new NumberFormatException();
+                                    }
+                                    itm.setGID(gid); 
+                                }
+                                catch (NumberFormatException x)
+                                {
+                                    syntaxError = true;
+                                    l.error("Syntax error on line {} of file {}: {}", lne, path, "Block2 muss eine Ganzzahl >=0 sein");
+                                    itm.setGID(0);
+                                }
+                            }
+                            else
+                            {
+                                syntaxError=true;
+                                l.error("Syntax error on line {} of file {}: {}",lne,path,"Could not determine Metadata block type");
+                            }
+                        }
+                    }
+                    else
+                    {
+                        if(ln.startsWith("#EXTINF"))
+                        {
+                            extinf=true;
+                            itm.setTitle(ln);
+                            encounteredParseableLine=true;
+                        }
+                        else
+                        {
+                            if(!ln.startsWith("#"))
+                            {
+                                if(!extinf)
+                                {
+                                    itm.setTitle("#EXTINF,0,"+new File(ln).getName());
+                                }
+                                if(!(ln.substring(1).startsWith(":")||ln.startsWith(File.separator)))
+                                {
+                                    ln=plbd+ln;//relative pfade absolutisieren
+                                }
+                                itm.setPath(ln);
+                                itm.setPrefix(itmprefix.toArray(new String[]{}));
+                                itm.setInlineCOmmentLines(itmprefix.toArray(new String[]{}));
+                                returndata.add(itm);
+                                itm=new SinglePlayListItem();
+                                extinf=false;
+                                itmprefix.clear();
+                                itmsuffix.clear();
+                                tail.clear();
+                            }
+                            else
+                            {
+                                if(encounteredParseableLine)
+                                {
+                                    tail.add(ln);
+                                    itmsuffix.add(ln);
+                                }
+                                else
+                                {
+                                    tail.add(ln);
+                                    itmprefix.add(ln);
+                                }
+                            }
+                        }
+                    }
+                }
+                lne++;
+                ln=fr.readLine();
+            }
+            if(syntaxError)
+            {
+                throw new InvalidPlayListFileException();
+            }
+            fr.close();
+            return new RawPlayListFile(rootDir,returndata,tail.toArray(new String[]{}));
+        }
+        catch (IOException ex)
+        {
+            return new RawPlayListFile("", new ArrayList<SinglePlayListItem>());
+        }
+    }
+    
+    public static List<PlayListItem> parseFullList(String path) throws InvalidPlayListFileException
+    {
+        return parseFullList(path, 40,false);
+        
+    }
+    
+    public static List<PlayListItem> parseFullList(String path,int rd) throws InvalidPlayListFileException
+    {
+        return parseFullList(path, rd,false);
+    }
+    
+    public static List<PlayListItem> parseFullList(String path,int rd,boolean singelifyMultiItems) throws InvalidPlayListFileException
+    {
+        
+    HashMap<Integer,MultiPlayListItem> groups = new HashMap<>();
+    List<PlayListItem> result = new ArrayList<>();
+
+        List<SinglePlayListItem> rootList = readSingleList(path).getData();
+        try{
+            Class yaml = Class.forName("org.yaml.snakeyaml.Yaml");
+            Object y = yaml.getConstructor().newInstance();
+            l.trace(yaml.getMethod("dump", Object.class).invoke(y, rootList));
+        }
+        catch(Exception e)
+        {
+        
+        }
+        for (SinglePlayListItem re : rootList)
+        {
+            if(re.isIncludeElement())
+            {
+                if(re.noexpandoninclude())
+                {
+                    MultiPlayListItem m = processNoExpandInclude(re.getPath(),rd);
+                    if(m!=null)
+                    {
+                        m.setTargetPlaycount(re.getTargetPlaycount());
+                        if(singelifyMultiItems)
+                        {
+                            result.addAll(Arrays.asList(m.getSinglePlayListElements()));
+                        }
+                        else
+                        {
+                            result.add(m);
+                        }
+                    }
+                }
+                else
+                {
+                    List<PlayListItem> temp = parseFullList(re.getPath(),rd-1);
+                    for (PlayListItem ple : temp)
+                    {
+                        ple.setTargetPlaycount(ple.getTargetPlaycount()*re.getTargetPlaycount());
+                    }
+                    result.addAll(temp);
+                }
+            }
+            else
+            {
+                int gid=re.getGID();
+                if(gid==0)
+                {
+                    result.add(re);
+                }
+                else
+                {
+                    if(!groups.containsKey(gid))
+                    {
+                        groups.put(gid,new MultiPlayListItem());
+                    }
+                    MultiPlayListItem gt = groups.get(gid);
+                    gt.addItem(re);
+                }
+            }
+        }
+        return result;
+    }
+    
+    private static MultiPlayListItem processNoExpandInclude(String path,int rd) throws InvalidPlayListFileException
+    {
+        MultiPlayListItem mi = new MultiPlayListItem();
+        if(rd<0)
+        {
+            return null;
+        }
+        rd--;
+        List<SinglePlayListItem> raw = readSingleList(path).getData();
+        for (SinglePlayListItem spi : raw)
+        {
+            if(spi.isIncludeElement())
+            {
+                mi.addItem(processNoExpandInclude(spi.getPath(), rd));
+            }
+            else
+            {
+                mi.addItem(spi);
+            }
+        }
+        return mi;
+    }
+    
+    public static void writePLFile(PlayListFile f)
+    {
+        // Arbeit mit derPath-Klasse & der File.getPath() methode, Reflection dient zur Kompatibilität mitSystemen ohne dieser Klasse (wie Androiden)
+        try{
+            boolean supportinRelativeness=false;
+            Object basepath = null;
+            Class pathclass=null;
+            try
+            {
+                pathclass = Class.forName("java.nio.file.Path");
+                supportinRelativeness=true;
+            }
+            catch(ClassNotFoundException x)
+            {
+                //Nix da wenn der error auftritt nur ein feature deaktiviert wird
+            }
+            Method pfadheraberdalli = File.class.getMethod("toPath");
+            
+            if(supportinRelativeness)
+            {
+                File magix = new File(f.getPath()).getParentFile();
+                basepath =  pfadheraberdalli.invoke(magix);
+            }
+            try
+            {
+                String fp = f.getPath();
+                String pld = "#EXTM3U\n#IZPL\n";
+                for (SinglePlayListItem pli : f.getEntries())
+                {
+                    String pathOfFile = pli.getPath();
+                            
+                    if(supportinRelativeness)
+                    {
+                        Method rel=pathclass.getMethod("relativize", (Class)pathclass);
+                        File current = new File(pathOfFile);
+                        Object pa = pfadheraberdalli.invoke(current);
+                        l.trace("pa-Class:"+pa.getClass());
+                        Object figgdi = rel.invoke(basepath, pa);
+                        l.trace("figgdi-Class:"+figgdi.getClass());
+                        pathOfFile=figgdi+"";
+                    }
+                           // = p.relativize(new File().toPath()).toString();
+
+
+                    if(pli.isIncludeElement())
+                    {
+                        pld+="#IZPL:INCLUDE|"+pli.getTargetPlaycount()+"|"+(pli.noexpandoninclude()?"NOEXPAND":"EXPAND")+"\n"+pathOfFile+"\n";
+                    }
+                    else
+                    {
+                        pld+=pli.getTitle()+"\n"+"#IZPL:"+pli.getTargetPlaycount()+"|"+pli.getGID()+"\n"+pathOfFile+"\n";
+                    }
+                }
+                RandomAccessFile file = new RandomAccessFile(fp, "rw");
+                file.setLength(0);
+                file.write(pld.getBytes());
+                file.close();
+            }
+            catch (IOException ex)
+            {
+                ex.printStackTrace();
+            }
+        }
+        catch(NoSuchMethodException |IllegalAccessException | IllegalArgumentException | InvocationTargetException ex)
+        {
+            ex.printStackTrace();
+        }
+    }
+    
+    
+    
+    private PLFileIO()
+    {
+    }
+    
+    
+}