Correct application to be in line with rapidly changing libKonogonka [so-called] api
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
dc45dabd34
commit
f7d3317bf5
12 changed files with 73 additions and 160 deletions
30
pom.xml
30
pom.xml
|
@ -54,28 +54,28 @@
|
|||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-controls</artifactId>
|
||||
<version>11</version>
|
||||
<version>19</version>
|
||||
<classifier>linux</classifier>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-media</artifactId>
|
||||
<version>11</version>
|
||||
<version>19</version>
|
||||
<classifier>linux</classifier>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-fxml</artifactId>
|
||||
<version>11</version>
|
||||
<version>19</version>
|
||||
<classifier>linux</classifier>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-graphics</artifactId>
|
||||
<version>11</version>
|
||||
<version>19</version>
|
||||
<classifier>linux</classifier>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
@ -83,28 +83,28 @@
|
|||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-controls</artifactId>
|
||||
<version>11</version>
|
||||
<version>19</version>
|
||||
<classifier>win</classifier>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-media</artifactId>
|
||||
<version>11</version>
|
||||
<version>19</version>
|
||||
<classifier>win</classifier>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-fxml</artifactId>
|
||||
<version>11</version>
|
||||
<version>19</version>
|
||||
<classifier>win</classifier>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-graphics</artifactId>
|
||||
<version>11</version>
|
||||
<version>19</version>
|
||||
<classifier>win</classifier>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
@ -112,28 +112,28 @@
|
|||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-controls</artifactId>
|
||||
<version>11</version>
|
||||
<version>19</version>
|
||||
<classifier>mac</classifier>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-media</artifactId>
|
||||
<version>11</version>
|
||||
<version>19</version>
|
||||
<classifier>mac</classifier>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-fxml</artifactId>
|
||||
<version>11</version>
|
||||
<version>19</version>
|
||||
<classifier>mac</classifier>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-graphics</artifactId>
|
||||
<version>11</version>
|
||||
<version>19</version>
|
||||
<classifier>mac</classifier>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
@ -148,19 +148,19 @@
|
|||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>5.5.2</version>
|
||||
<version>5.9.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.5.2</version>
|
||||
<version>5.9.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-params</artifactId>
|
||||
<version>5.5.2</version>
|
||||
<version>5.9.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- Consider removing
|
||||
|
|
|
@ -30,6 +30,7 @@ import libKonogonka.Tools.ISuperProvider;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class ChildWindow {
|
||||
|
@ -69,11 +70,11 @@ public class ChildWindow {
|
|||
|
||||
// TODO: fix?
|
||||
if(model.getFileName().endsWith(".xml")){
|
||||
XMLController myController = loaderSettings.<XMLController>getController();
|
||||
XMLController myController = loaderSettings.getController();
|
||||
myController.analyze(provider.getFile(), provider.getRawFileDataStart()+model.getFileOffset(), model.getFileSize());
|
||||
}
|
||||
else if (model.getFileName().endsWith(".npdm")){
|
||||
ITabController myController = loaderSettings.<ITabController>getController();
|
||||
ITabController myController = loaderSettings.getController();
|
||||
try {
|
||||
myController.analyze(provider, model.getNumber());
|
||||
}
|
||||
|
@ -82,17 +83,17 @@ public class ChildWindow {
|
|||
}
|
||||
}
|
||||
else {
|
||||
ITabController myController = loaderSettings.<ITabController>getController();
|
||||
ITabController myController = loaderSettings.getController();
|
||||
myController.analyze(provider.getFile(), provider.getRawFileDataStart()+model.getFileOffset());
|
||||
}
|
||||
|
||||
|
||||
stageSettings.setTitle(model.getFileName());
|
||||
stageSettings.getIcons().addAll(
|
||||
new Image(getClass().getResourceAsStream("/res/app_icon32x32.png")),
|
||||
new Image(getClass().getResourceAsStream("/res/app_icon48x48.png")),
|
||||
new Image(getClass().getResourceAsStream("/res/app_icon64x64.png")),
|
||||
new Image(getClass().getResourceAsStream("/res/app_icon128x128.png"))
|
||||
new Image(Objects.requireNonNull(getClass().getResourceAsStream("/res/app_icon32x32.png"))),
|
||||
new Image(Objects.requireNonNull(getClass().getResourceAsStream("/res/app_icon48x48.png"))),
|
||||
new Image(Objects.requireNonNull(getClass().getResourceAsStream("/res/app_icon64x64.png"))),
|
||||
new Image(Objects.requireNonNull(getClass().getResourceAsStream("/res/app_icon128x128.png")))
|
||||
);
|
||||
Scene settingsScene = new Scene(parentAbout, 800, 800);
|
||||
settingsScene.getStylesheets().add("/res/app_light.css");
|
||||
|
|
|
@ -262,7 +262,6 @@ public class MainController implements Initializable {
|
|||
catch (IOException e){
|
||||
logArea.appendText("\nUnable to create windows for "+model.getFileName()+"\n"+e.getMessage());
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
public void exit(){ AppPreferences.getInstance().setRecentPath(previouslyOpenedPath); }
|
||||
}
|
|
@ -33,7 +33,7 @@ import libKonogonka.Converter;
|
|||
import konogonka.MediatorControl;
|
||||
import libKonogonka.Tools.NCA.NCAContent;
|
||||
import konogonka.Workers.DumbNCA3ContentExtractor;
|
||||
import libKonogonka.Tools.PFS0.IPFS0Provider;
|
||||
import libKonogonka.Tools.PFS0.PFS0Provider;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
|
@ -86,7 +86,7 @@ public class NCASectionContentController implements Initializable {
|
|||
if (ncaContent.getPfs0() != null)
|
||||
SectionPFS0Controller.setData(ncaContent.getPfs0(), null);;
|
||||
|
||||
IPFS0Provider ipfs0Provider = ncaContent.getPfs0();
|
||||
PFS0Provider ipfs0Provider = ncaContent.getPfs0();
|
||||
|
||||
if (ipfs0Provider == null)
|
||||
return;
|
||||
|
|
|
@ -27,7 +27,6 @@ import konogonka.Controllers.IRowModel;
|
|||
import konogonka.Controllers.ITabController;
|
||||
import konogonka.MediatorControl;
|
||||
import libKonogonka.Tools.ISuperProvider;
|
||||
import libKonogonka.Tools.PFS0.IPFS0Provider;
|
||||
import libKonogonka.Tools.PFS0.PFS0Provider;
|
||||
import konogonka.Workers.Analyzer;
|
||||
import konogonka.Workers.Extractor;
|
||||
|
@ -70,7 +69,7 @@ public class NSPController implements ITabController {
|
|||
List<IRowModel> models = tableFilesListController.getFilesForDump();
|
||||
ISuperProvider provider = tableFilesListController.getProvider();
|
||||
if (models != null && !models.isEmpty() && (provider != null)){
|
||||
File dir = new File(AppPreferences.getInstance().getExtractFilesDir()+File.separator+provider.getFile().getName()+" extracted");
|
||||
File dir = new File(AppPreferences.getInstance().getExtractFilesDir()+File.separator+provider+" extracted");
|
||||
try {
|
||||
dir.mkdir();
|
||||
}
|
||||
|
@ -132,12 +131,12 @@ public class NSPController implements ITabController {
|
|||
/**
|
||||
* Just populate fields by already analyzed PFS0
|
||||
* */
|
||||
public void setData(IPFS0Provider pfs0, File fileWithNca){
|
||||
public void setData(PFS0Provider pfs0, File fileWithNca){
|
||||
if (pfs0 == null)
|
||||
return;
|
||||
this.selectedFile = fileWithNca;
|
||||
|
||||
filesCountLbl.setText(Integer.toString(pfs0.getFilesCount()));
|
||||
filesCountLbl.setText(Integer.toString(pfs0.getHeader().getFilesCount()));
|
||||
RawDataStartLbl.setText(Long.toString(pfs0.getRawFileDataStart()));
|
||||
rawFileDataStart = pfs0.getRawFileDataStart();
|
||||
tableFilesListController.setNSPToTable(pfs0);
|
||||
|
@ -147,13 +146,14 @@ public class NSPController implements ITabController {
|
|||
NSPSizeLbl.setText(Long.toString(selectedFile.length()));
|
||||
|
||||
extractBtn.setDisable(false);
|
||||
magicLbl.setText(pfs0.getMagic());
|
||||
stringTableSizeLbl.setText(Integer.toString(pfs0.getStringTableSize()));
|
||||
paddingLbl.setText(byteArrToHexString(pfs0.getPadding()));
|
||||
magicLbl.setText(pfs0.getHeader().getMagic());
|
||||
stringTableSizeLbl.setText(Integer.toString(pfs0.getHeader().getStringTableSize()));
|
||||
paddingLbl.setText(byteArrToHexString(pfs0.getHeader().getPadding()));
|
||||
|
||||
fileEntryTableSizeLbl.setText(String.format("0x%02x", 0x18* pfs0.getFilesCount()));
|
||||
stringsTableSizeLbl.setText(String.format("0x%02x", pfs0.getStringTableSize()));
|
||||
stringsTableOffsetLbl.setText(String.format("0x%02x", 0x18* pfs0.getFilesCount()+0x10));
|
||||
rawFileDataOffsetLbl.setText(String.format("0x%02x", 0x18* pfs0.getFilesCount()+0x10+ pfs0.getStringTableSize())); // same to RawFileDataStart for NSP ONLY
|
||||
fileEntryTableSizeLbl.setText(String.format("0x%02x", 0x18* pfs0.getHeader().getFilesCount()));
|
||||
stringsTableSizeLbl.setText(String.format("0x%02x", pfs0.getHeader().getStringTableSize()));
|
||||
stringsTableOffsetLbl.setText(String.format("0x%02x", 0x18* pfs0.getHeader().getFilesCount()+0x10));
|
||||
rawFileDataOffsetLbl.setText(String.format("0x%02x", 0x18* pfs0.getHeader().getFilesCount()+0x10+
|
||||
pfs0.getHeader().getStringTableSize())); // same to RawFileDataStart for NSP ONLY
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,8 @@ import javafx.scene.input.MouseButton;
|
|||
import konogonka.Controllers.IRowModel;
|
||||
import konogonka.MediatorControl;
|
||||
import libKonogonka.Tools.ISuperProvider;
|
||||
import libKonogonka.Tools.PFS0.IPFS0Provider;
|
||||
import libKonogonka.Tools.PFS0.PFS0Provider;
|
||||
import libKonogonka.Tools.PFS0.PFS0subFile;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
|
@ -166,7 +167,7 @@ public class Pfs0TableViewController implements Initializable {
|
|||
/**
|
||||
* Add files when user selected them
|
||||
* */
|
||||
public void setNSPToTable(IPFS0Provider pfs){
|
||||
public void setNSPToTable(PFS0Provider pfs){
|
||||
this.provider = pfs;
|
||||
rowsObsLst.clear();
|
||||
Pfs0RowModel.resetNumCnt();
|
||||
|
@ -174,12 +175,12 @@ public class Pfs0TableViewController implements Initializable {
|
|||
table.refresh();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i=0; i < pfs.getFilesCount(); i++){
|
||||
PFS0subFile pfs0subFiles[] = pfs.getHeader().getPfs0subFiles();
|
||||
for (int i=0; i < pfs.getHeader().getFilesCount(); i++){
|
||||
rowsObsLst.add(new Pfs0RowModel(
|
||||
pfs.getPfs0subFiles()[i].getName(),
|
||||
pfs.getPfs0subFiles()[i].getSize(),
|
||||
pfs.getPfs0subFiles()[i].getOffset()
|
||||
pfs0subFiles[i].getName(),
|
||||
pfs0subFiles[i].getSize(),
|
||||
pfs0subFiles[i].getOffset()
|
||||
));
|
||||
}
|
||||
table.refresh();
|
||||
|
|
|
@ -27,7 +27,6 @@ import konogonka.Controllers.ITabController;
|
|||
import konogonka.MediatorControl;
|
||||
import libKonogonka.Tools.ISuperProvider;
|
||||
import libKonogonka.Tools.RomFs.FileSystemEntry;
|
||||
import libKonogonka.Tools.RomFs.IRomFsProvider;
|
||||
import libKonogonka.Tools.RomFs.Level6Header;
|
||||
import konogonka.Workers.Analyzer;
|
||||
import konogonka.Workers.DumbRomFsExtractor;
|
||||
|
@ -66,7 +65,7 @@ public class RomFsController implements ITabController {
|
|||
@FXML
|
||||
private TreeView<RFSModelEntry> filesTreeView;
|
||||
|
||||
private IRomFsProvider provider;
|
||||
private RomFsProvider provider;
|
||||
|
||||
@FXML
|
||||
private RFSFolderTableViewController RFSTableViewController;
|
||||
|
@ -87,7 +86,7 @@ public class RomFsController implements ITabController {
|
|||
extractBtn.setOnAction(event -> extractSelectedBtn());
|
||||
}
|
||||
private void extractRootBtn(){
|
||||
File dir = new File(AppPreferences.getInstance().getExtractFilesDir()+File.separator+ provider.getFile().getName()+" extracted");
|
||||
File dir = new File(AppPreferences.getInstance().getExtractFilesDir()+File.separator+provider.toString()+" extracted");
|
||||
try {
|
||||
dir.mkdir();
|
||||
}
|
||||
|
@ -164,7 +163,7 @@ public class RomFsController implements ITabController {
|
|||
workThread.start();
|
||||
}
|
||||
|
||||
public void setData(IRomFsProvider provider) {
|
||||
public void setData(RomFsProvider provider) {
|
||||
try {
|
||||
this.provider = provider;
|
||||
Level6Header header = provider.getHeader();
|
||||
|
|
|
@ -25,13 +25,13 @@ public class Hfs0RowModel implements IRowModel {
|
|||
private static int numberCnt = 0;
|
||||
public static void resetNumCnt(){ numberCnt = 0; }
|
||||
|
||||
private int number;
|
||||
private String fileName;
|
||||
private long fileSize;
|
||||
private long fileOffset;
|
||||
private long hashedRegionSize;
|
||||
private boolean padding;
|
||||
private String SHA256Hash;
|
||||
private final int number;
|
||||
private final String fileName;
|
||||
private final long fileSize;
|
||||
private final long fileOffset;
|
||||
private final long hashedRegionSize;
|
||||
private final boolean padding;
|
||||
private final String SHA256Hash;
|
||||
private boolean markForUpload;
|
||||
|
||||
Hfs0RowModel(String fileName, long size, long offset, long hashedRegionSize, boolean padding, byte[] SHA256Hash){
|
||||
|
|
|
@ -34,7 +34,6 @@ import javafx.scene.control.cell.PropertyValueFactory;
|
|||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.input.MouseButton;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.util.Callback;
|
||||
import konogonka.Controllers.IRowModel;
|
||||
import konogonka.MediatorControl;
|
||||
|
|
|
@ -107,7 +107,7 @@ public class Analyzer {
|
|||
protected NPDMProvider call() {
|
||||
logPrinter.print("\tStart chain: NPDM [stream]", EMsgType.INFO);
|
||||
try{
|
||||
return new NPDMProvider(parentProvider.getProviderSubFilePipedInpStream(fileNo));
|
||||
return new NPDMProvider(parentProvider.getStreamProducer(fileNo));
|
||||
}
|
||||
catch (Exception e){
|
||||
logPrinter.print("\tException: "+e.getMessage(), EMsgType.FAIL);
|
||||
|
|
|
@ -4,31 +4,26 @@ import javafx.concurrent.Task;
|
|||
import konogonka.ModelControllers.EMsgType;
|
||||
import konogonka.ModelControllers.LogPrinter;
|
||||
import libKonogonka.Tools.RomFs.FileSystemEntry;
|
||||
import libKonogonka.Tools.RomFs.IRomFsProvider;
|
||||
import libKonogonka.Tools.RomFs.RomFsProvider;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.PipedInputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
|
||||
public class DumbRomFsExtractor extends Task<Void> {
|
||||
|
||||
private IRomFsProvider provider;
|
||||
private final RomFsProvider provider;
|
||||
private FileSystemEntry entry;
|
||||
private List<FileSystemEntry> entries;
|
||||
private LogPrinter logPrinter;
|
||||
private String filesDestPath;
|
||||
private final LogPrinter logPrinter;
|
||||
private final String filesDestPath;
|
||||
|
||||
public DumbRomFsExtractor(IRomFsProvider provider, List<FileSystemEntry> entries, String filesDestPath){
|
||||
public DumbRomFsExtractor(RomFsProvider provider, List<FileSystemEntry> entries, String filesDestPath){
|
||||
this.provider = provider;
|
||||
this.entries = entries;
|
||||
this.filesDestPath = filesDestPath;
|
||||
this.logPrinter = new LogPrinter();
|
||||
}
|
||||
|
||||
public DumbRomFsExtractor(IRomFsProvider provider, FileSystemEntry entry, String filesDestPath){
|
||||
public DumbRomFsExtractor(RomFsProvider provider, FileSystemEntry entry, String filesDestPath){
|
||||
this.provider = provider;
|
||||
this.entry = entry;
|
||||
this.filesDestPath = filesDestPath;
|
||||
|
@ -40,21 +35,13 @@ public class DumbRomFsExtractor extends Task<Void> {
|
|||
try {
|
||||
if (this.entries == null){
|
||||
logPrinter.print("\tStart dummy extracting from 'RomFs' image: \n"+filesDestPath+entry.getName(), EMsgType.INFO);
|
||||
if (entry.isFile())
|
||||
exportSingleFile(entry, filesDestPath);
|
||||
else
|
||||
exportFolderContent(entry, filesDestPath);
|
||||
provider.exportContent(filesDestPath, entry);
|
||||
}
|
||||
else {
|
||||
logPrinter.print("\tStart dummy extracting from 'RomFs' image: \n"+filesDestPath+"...", EMsgType.INFO);
|
||||
for (FileSystemEntry e : entries){
|
||||
if (e.isFile())
|
||||
exportSingleFile(e, filesDestPath);
|
||||
else
|
||||
exportFolderContent(e, filesDestPath);
|
||||
for (FileSystemEntry e : entries)
|
||||
provider.exportContent(filesDestPath, e);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception ioe) {
|
||||
logPrinter.print("\tDummy extracting from 'RomFs' image issue\n\t" + ioe.getMessage(), EMsgType.INFO);
|
||||
return null;
|
||||
|
@ -64,47 +51,4 @@ public class DumbRomFsExtractor extends Task<Void> {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
// TODO: Update # backend and then here
|
||||
private void exportSingleFile(FileSystemEntry entry, String saveToLocation) throws Exception{
|
||||
File contentFile = new File(saveToLocation + entry.getName());
|
||||
|
||||
BufferedOutputStream extractedFileBOS = new BufferedOutputStream(Files.newOutputStream(contentFile.toPath()));
|
||||
PipedInputStream pis = provider.getContent(entry);
|
||||
|
||||
byte[] readBuf = new byte[0x200]; // 8mb NOTE: consider switching to 1mb 1048576
|
||||
int readSize;
|
||||
//*** PROGRESS BAR VARS START
|
||||
long progressHandleFSize = entry.getSize();
|
||||
int progressHandleFRead = 0;
|
||||
//*** PROGRESS BAR VARS END
|
||||
while ((readSize = pis.read(readBuf)) > -1) {
|
||||
extractedFileBOS.write(readBuf, 0, readSize);
|
||||
readBuf = new byte[0x200];
|
||||
//*** PROGRESS BAR DECORCATIONS START
|
||||
progressHandleFRead += readSize;
|
||||
//System.out.println(readSize);
|
||||
try {
|
||||
logPrinter.updateProgress((progressHandleFRead)/(progressHandleFSize/100.0) / 100.0);
|
||||
}catch (InterruptedException ignore){}
|
||||
//*** PROGRESS BAR DECORCATIONS END
|
||||
}
|
||||
try {
|
||||
logPrinter.updateProgress(1.0);
|
||||
}
|
||||
catch (InterruptedException ignored){}
|
||||
|
||||
extractedFileBOS.close();
|
||||
}
|
||||
|
||||
private void exportFolderContent(FileSystemEntry entry, String saveToLocation) throws Exception{
|
||||
File contentFile = new File(saveToLocation + entry.getName());
|
||||
contentFile.mkdirs();
|
||||
String currentDirPath = saveToLocation + entry.getName() + File.separator;
|
||||
for (FileSystemEntry fse : entry.getContent()){
|
||||
if (fse.isDirectory())
|
||||
exportFolderContent(fse, currentDirPath);
|
||||
else
|
||||
exportSingleFile(fse, currentDirPath);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -24,61 +24,31 @@ import konogonka.ModelControllers.EMsgType;
|
|||
import konogonka.ModelControllers.LogPrinter;
|
||||
import libKonogonka.Tools.ISuperProvider;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.List;
|
||||
|
||||
public class Extractor extends Task<Void> {
|
||||
|
||||
private ISuperProvider provider;
|
||||
private List<IRowModel> models;
|
||||
private LogPrinter logPrinter;
|
||||
private final ISuperProvider provider;
|
||||
private final List<IRowModel> models;
|
||||
private final LogPrinter logPrinter;
|
||||
|
||||
private String filesDestPath;
|
||||
private final String filesDestinationPath;
|
||||
|
||||
public Extractor(ISuperProvider provider, List<IRowModel> models, String filesDestPath){
|
||||
public Extractor(ISuperProvider provider, List<IRowModel> models, String filesDestinationPath){
|
||||
this.provider = provider;
|
||||
this.models = models;
|
||||
this.filesDestPath = filesDestPath;
|
||||
this.filesDestinationPath = filesDestinationPath;
|
||||
this.logPrinter = new LogPrinter();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void call() {
|
||||
for (IRowModel model : models) {
|
||||
logPrinter.print("\tStart extracting: \n"+filesDestPath+model.getFileName(), EMsgType.INFO);
|
||||
File contentFile = new File(filesDestPath + model.getFileName());
|
||||
logPrinter.print("\tStart extracting: \n"+ filesDestinationPath +model.getFileName(), EMsgType.INFO);
|
||||
try {
|
||||
BufferedOutputStream extractedFileBOS = new BufferedOutputStream(new FileOutputStream(contentFile));
|
||||
PipedInputStream pis = provider.getProviderSubFilePipedInpStream(model.getNumber());
|
||||
|
||||
byte[] readBuf = new byte[0x800000]; // 8mb NOTE: consider switching to 1mb 1048576
|
||||
int readSize;
|
||||
//*** PROGRESS BAR VARS START
|
||||
long progressHandleFSize = model.getFileSize();
|
||||
int progressHandleFRead = 0;
|
||||
//*** PROGRESS BAR VARS END
|
||||
while ((readSize = pis.read(readBuf)) > -1) {
|
||||
extractedFileBOS.write(readBuf, 0, readSize);
|
||||
readBuf = new byte[0x800000];
|
||||
//*** PROGRESS BAR DECORCATIONS START
|
||||
progressHandleFRead += readSize;
|
||||
//System.out.println(readSize);
|
||||
try {
|
||||
logPrinter.updateProgress((progressHandleFRead)/(progressHandleFSize/100.0) / 100.0);
|
||||
}catch (InterruptedException ie){
|
||||
getException().printStackTrace(); // TODO: Do something with this
|
||||
}
|
||||
//*** PROGRESS BAR DECORCATIONS END
|
||||
}
|
||||
try {
|
||||
logPrinter.updateProgress(1.0);
|
||||
}catch (InterruptedException ie){
|
||||
getException().printStackTrace(); // TODO: Do something with this
|
||||
}
|
||||
extractedFileBOS.close();
|
||||
provider.exportContent(filesDestinationPath, model.getNumber());
|
||||
} catch (Exception ioe) {
|
||||
logPrinter.print("\tExtracting issue\n\t" + ioe.getMessage(), EMsgType.INFO);
|
||||
return null;
|
||||
} finally {
|
||||
logPrinter.print("\tEnd extracting", EMsgType.INFO);
|
||||
logPrinter.close();
|
||||
|
|
Loading…
Reference in a new issue