|
@@ -24,7 +24,11 @@ import de.nplusc.izc.iZpl.API.shared.RawPlayListFile;
|
|
|
import de.nplusc.izc.iZpl.API.shared.SinglePlayListItem;
|
|
|
import de.nplusc.izc.iZpl.Utils.shared.PLFileIO;
|
|
|
import de.nplusc.izc.tools.IOtools.FileTK;
|
|
|
+import hu.ssh.progressbar.console.ConsoleProgressBar;
|
|
|
import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.nio.file.Files;
|
|
|
+import java.nio.file.StandardCopyOption;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -38,7 +42,8 @@ import org.apache.logging.log4j.Logger;
|
|
|
public class Extractor implements FeaturePlugin
|
|
|
{
|
|
|
private static final Logger l = LogManager.getLogger(Extractor.class.getName());
|
|
|
-
|
|
|
+ private ConsoleProgressBar progressBar;
|
|
|
+ private int copyIndex = 0;
|
|
|
@Override
|
|
|
public void parseParameter(String param)
|
|
|
{
|
|
@@ -56,10 +61,34 @@ public class Extractor implements FeaturePlugin
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- String targetDir = new File(".").getAbsolutePath();
|
|
|
+ String targetDir = new File("extracted").getAbsolutePath();
|
|
|
try
|
|
|
{
|
|
|
- getCopyStepList(basePath, targetDir, absoluteiZplPath);
|
|
|
+ HashMap<String,String> scheduledCopyMes = getCopyStepList(basePath, targetDir, absoluteiZplPath);
|
|
|
+ progressBar = ConsoleProgressBar.on(System.out)
|
|
|
+ .withFormat("[:bar] :percent% :elapsed/:total :msg")
|
|
|
+ .withTotalSteps(scheduledCopyMes.size());
|
|
|
+ progressBar.start();
|
|
|
+ final int total = scheduledCopyMes.size();
|
|
|
+ progressBar.setMessage("Copying:" + 0 + "/" + total);
|
|
|
+ l.info("Transferring [} files",scheduledCopyMes.size());
|
|
|
+ scheduledCopyMes.forEach((source,target)->
|
|
|
+ {
|
|
|
+
|
|
|
+ FileTK.ensuredirExistence(target);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ l.trace("({}/{}) Copying {} to {}",copyIndex,total,source,target);
|
|
|
+ Files.copy(new File(source).toPath(), new File(target).toPath(),StandardCopyOption.REPLACE_EXISTING);
|
|
|
+ progressBar.tickOne();
|
|
|
+ }
|
|
|
+ catch (IOException ex)
|
|
|
+ {
|
|
|
+ l.warn("\n\nInvalid file {}->{}\n\n",source,target);
|
|
|
+ }
|
|
|
+ copyIndex++;
|
|
|
+ progressBar.setMessage("Kopieren:" + copyIndex + "/" + total);
|
|
|
+ });
|
|
|
}
|
|
|
catch(InvalidPlayListFileException e)
|
|
|
{
|
|
@@ -103,21 +132,30 @@ public class Extractor implements FeaturePlugin
|
|
|
for (SinglePlayListItem currentEntry : currentEntries)
|
|
|
{
|
|
|
File newItem = new File(currentEntry.getPath());
|
|
|
+ String absoluteEntryPath = newItem.getAbsolutePath();
|
|
|
+ String relativeEntryPath = FileTK.getRelativePath(absoluteEntryPath, baseDir);
|
|
|
+ if(relativeEntryPath.equals(absoluteEntryPath)||relativeEntryPath.startsWith(".."))
|
|
|
+ {
|
|
|
+ l.error("File not inside base folder. Cannot continue.");
|
|
|
+ IZPLApi.quickQuitWithoutSaving();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
if(currentEntry.isIncludeElement())
|
|
|
{
|
|
|
scheduledPaths.add(currentEntry.getPath());
|
|
|
+ moreToHandle=true;
|
|
|
+ results.put(baseDir+File.separator+relativeEntryPath, targetDir+File.separator+relativeEntryPath);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
-
|
|
|
+ results.put(baseDir+File.separator+relativeEntryPath, targetDir+File.separator+relativeEntryPath);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
- return null;
|
|
|
+ return results;
|
|
|
}
|
|
|
|
|
|
|