diff --git a/README.md b/README.md index 8c0ad16..4dd0459 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # konogonka -[![Build Status](https://ci.redrise.ru/api/badges/desu/konogonka/status.svg)](https://ci.redrise.ru/desu/konogonka) +![License](https://img.shields.io/badge/License-GPLv3-blue.svg) [![Build Status](https://ci.redrise.ru/api/badges/desu/konogonka/status.svg)](https://ci.redrise.ru/desu/konogonka) GitHub mirror. [Click here to get it from independent source code location](https://git.redrise.ru/desu/konogonka) diff --git a/src/main/java/konogonka/Controllers/NCA/NCASectionContentController.java b/src/main/java/konogonka/Controllers/NCA/NCASectionContentController.java index f83ba91..8b737f3 100644 --- a/src/main/java/konogonka/Controllers/NCA/NCASectionContentController.java +++ b/src/main/java/konogonka/Controllers/NCA/NCASectionContentController.java @@ -23,6 +23,7 @@ import javafx.fxml.Initializable; import javafx.geometry.Insets; import javafx.scene.control.Button; import javafx.scene.control.Label; +import javafx.scene.control.TitledPane; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import konogonka.AppPreferences; @@ -32,6 +33,7 @@ import libKonogonka.Converter; import konogonka.MediatorControl; import libKonogonka.Tools.NCA.NCAContent; import konogonka.Workers.DumbNCA3ContentExtractor; +import libKonogonka.Tools.PFS0.IPFS0Provider; import java.io.File; import java.net.URL; @@ -44,25 +46,27 @@ public class NCASectionContentController implements Initializable { private int sectionNumber; @FXML - private Button extractRawConentBtn; + private Button extractRawContentBtn; @FXML private NSPController SectionPFS0Controller; @FXML private RomFsController SectionRomFsController; @FXML private VBox sha256pane; + @FXML + private TitledPane pfs0TitledPane, RomFsTitledPane; @Override public void initialize(URL url, ResourceBundle resourceBundle) { - extractRawConentBtn.setDisable(true); - extractRawConentBtn.setOnAction(event -> this.extractFiles()); + extractRawContentBtn.setDisable(true); + extractRawContentBtn.setOnAction(event -> this.extractFiles()); } public void resetTab() { SectionPFS0Controller.resetTab(); SectionRomFsController.resetTab(); sha256pane.getChildren().clear(); - extractRawConentBtn.setDisable(true); + extractRawContentBtn.setDisable(true); } public void populateFields(NCAContent ncaContent, int sectionNumber) { @@ -73,7 +77,7 @@ public class NCASectionContentController implements Initializable { this.ncaContent = ncaContent; this.sectionNumber = sectionNumber; - this.extractRawConentBtn.setDisable(false); + this.extractRawContentBtn.setDisable(false); setPFS0Content(); setRomFsContent(); @@ -82,10 +86,16 @@ public class NCASectionContentController implements Initializable { if (ncaContent.getPfs0() != null) SectionPFS0Controller.setData(ncaContent.getPfs0(), null);; - LinkedList sha256hashList = ncaContent.getPfs0SHA256hashes(); + IPFS0Provider ipfs0Provider = ncaContent.getPfs0(); + + if (ipfs0Provider == null) + return; + + LinkedList sha256hashList = ipfs0Provider.getPfs0SHA256hashes(); if (sha256hashList == null) return; + for (int i = 0; i < sha256hashList.size(); i++){ Label numberLblTmp = new Label(String.format("%10d", i)); numberLblTmp.setPadding(new Insets(5.0, 5.0, 5.0, 5.0)); @@ -94,10 +104,13 @@ public class NCASectionContentController implements Initializable { sha256pane.getChildren().add(new HBox(numberLblTmp, sha256LblTmp)); } + pfs0TitledPane.setExpanded(true); } private void setRomFsContent(){ - if (ncaContent.getRomfs() != null) - SectionRomFsController.setData(ncaContent.getRomfs()); + if (ncaContent.getRomfs() == null) + return; + SectionRomFsController.setData(ncaContent.getRomfs()); + RomFsTitledPane.setExpanded(true); } private void extractFiles(){ @@ -114,11 +127,11 @@ public class NCASectionContentController implements Initializable { if (!dir.exists()) return; - extractRawConentBtn.setDisable(true); + extractRawContentBtn.setDisable(true); DumbNCA3ContentExtractor extractor = new DumbNCA3ContentExtractor(ncaContent, sectionNumber, dir.getAbsolutePath()+File.separator); extractor.setOnSucceeded(e->{ - extractRawConentBtn.setDisable(false); + extractRawContentBtn.setDisable(false); }); Thread workThread = new Thread(extractor); workThread.setDaemon(true); diff --git a/src/main/java/konogonka/Controllers/RFS/RFSModelEntry.java b/src/main/java/konogonka/Controllers/RFS/RFSModelEntry.java index 862d744..ac8cd95 100644 --- a/src/main/java/konogonka/Controllers/RFS/RFSModelEntry.java +++ b/src/main/java/konogonka/Controllers/RFS/RFSModelEntry.java @@ -50,10 +50,10 @@ public class RFSModelEntry implements IRowModel { public String getFileName() { return fileSystemEntry.getName(); } @Override - public long getFileSize() { return fileSystemEntry.getFileSize(); } + public long getFileSize() { return fileSystemEntry.getSize(); } @Override - public long getFileOffset() { return fileSystemEntry.getFileOffset(); } + public long getFileOffset() { return fileSystemEntry.getOffset(); } @Override public boolean isMarkSelected() { return check; } diff --git a/src/main/java/konogonka/Controllers/XCI/HFSBlockController.java b/src/main/java/konogonka/Controllers/XCI/HFSBlockController.java index 15f6f64..d63fab6 100644 --- a/src/main/java/konogonka/Controllers/XCI/HFSBlockController.java +++ b/src/main/java/konogonka/Controllers/XCI/HFSBlockController.java @@ -35,6 +35,8 @@ import java.net.URL; import java.util.List; import java.util.ResourceBundle; +import static libKonogonka.Converter.byteArrToHexString; + public class HFSBlockController implements Initializable { @FXML private TitledPane currentTitledPane; @@ -91,13 +93,13 @@ public class HFSBlockController implements Initializable { public void populateTab(HFS0Provider hfs0Provider){ if (hfs0Provider != null){ bodySize = hfs0Provider.getRawFileDataStart(); - hfs0mainMagicNumLbl.setText(Boolean.toString(hfs0Provider.isMagicHFS0())); - hfs0mainFileCntLbl.setText(Integer.toString(hfs0Provider.getFilesCnt())); + hfs0mainMagicNumLbl.setText(hfs0Provider.getMagic()); + hfs0mainFileCntLbl.setText(Integer.toString(hfs0Provider.getFilesCount())); hfs0mainStrTblSizeLbl.setText(Integer.toString(hfs0Provider.getStringTableSize())); - hfs0mainPaddingLbl.setText(Boolean.toString(hfs0Provider.isPaddingHfs0())); + hfs0mainPaddingLbl.setText(byteArrToHexString(hfs0Provider.getPadding())); hfs0mainRawFileDataStartLbl.setText(Long.toString(hfs0Provider.getRawFileDataStart())); hfs0tableFilesListMainController.setContentToTable(hfs0Provider); - if (hfs0Provider.getFilesCnt() > 0) + if (hfs0Provider.getFilesCount() > 0) extractMainBtn.setDisable(false); } else { diff --git a/src/main/java/konogonka/Controllers/XCI/Hfs0TableViewController.java b/src/main/java/konogonka/Controllers/XCI/Hfs0TableViewController.java index 85ed142..8e887bf 100644 --- a/src/main/java/konogonka/Controllers/XCI/Hfs0TableViewController.java +++ b/src/main/java/konogonka/Controllers/XCI/Hfs0TableViewController.java @@ -215,7 +215,7 @@ public class Hfs0TableViewController implements Initializable { return; } // Note: 'i' in here is extra important to be stored in sequence items added. - for (int i = 0; i < hfs0.getFilesCnt(); i++){ + for (int i = 0; i < hfs0.getFilesCount(); i++){ rowsObsLst.add(new Hfs0RowModel( hfs0.getHfs0Files()[i].getName(), hfs0.getHfs0Files()[i].getSize(), diff --git a/src/main/java/konogonka/Workers/DumbNCA3ContentExtractor.java b/src/main/java/konogonka/Workers/DumbNCA3ContentExtractor.java index 21ebd62..ff1b94b 100644 --- a/src/main/java/konogonka/Workers/DumbNCA3ContentExtractor.java +++ b/src/main/java/konogonka/Workers/DumbNCA3ContentExtractor.java @@ -5,22 +5,17 @@ import konogonka.ModelControllers.EMsgType; import konogonka.ModelControllers.LogPrinter; import libKonogonka.Tools.NCA.NCAContent; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.PipedInputStream; - public class DumbNCA3ContentExtractor extends Task { - private NCAContent ncaContent; - private int ncaNumberInFile; - private LogPrinter logPrinter; - private String filesDestPath; + private final NCAContent ncaContent; + private final int ncaNumberInFile; + private final LogPrinter logPrinter; + private final String filesDestinationPath; - public DumbNCA3ContentExtractor(NCAContent ncaContent, int ncaNumberInFile, String filesDestPath){ + public DumbNCA3ContentExtractor(NCAContent ncaContent, int ncaNumberInFile, String filesDestinationPath){ this.ncaContent = ncaContent; this.ncaNumberInFile = ncaNumberInFile; - this.filesDestPath = filesDestPath; + this.filesDestinationPath = filesDestinationPath; this.logPrinter = new LogPrinter(); } @@ -30,42 +25,10 @@ public class DumbNCA3ContentExtractor extends Task { if (ncaContent.getRomfs() != null){ lv6mark = " [lv6 "+ncaContent.getRomfs().getLevel6Offset()+"]"; } - logPrinter.print("\tStart dummy extracting: \n"+filesDestPath+"NCAContent_"+ncaNumberInFile+lv6mark+".bin", EMsgType.INFO); - File contentFile = new File(filesDestPath + "NCAContent_"+ncaNumberInFile+lv6mark+".bin"); - try { - BufferedOutputStream extractedFileBOS = new BufferedOutputStream(new FileOutputStream(contentFile)); - PipedInputStream pis = ncaContent.getRawDataContentPipedInpStream(); - - byte[] readBuf = new byte[0x200]; // 8mb NOTE: consider switching to 1mb 1048576 - int readSize; - //*** PROGRESS BAR VARS START - long progressHandleFSize = ncaContent.getRawDataContentSize(); - 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(); - - } catch (Exception ioe) { - logPrinter.print("\tExtracting dummy issue\n\t" + ioe.getMessage(), EMsgType.INFO); - return null; - } finally { - logPrinter.print("\tEnd dummy extracting", EMsgType.INFO); - logPrinter.close(); - } + logPrinter.print("\tStart dummy extracting: \n"+ filesDestinationPath +"NCAContent_"+ncaNumberInFile+lv6mark+".bin", EMsgType.INFO); + ncaContent.exportMediaBlock(filesDestinationPath + "NCAContent_"+ncaNumberInFile+lv6mark+".bin"); + logPrinter.print("\tEnd dummy extracting", EMsgType.INFO); + logPrinter.close(); return null; } } \ No newline at end of file diff --git a/src/main/java/konogonka/Workers/DumbRomFsExtractor.java b/src/main/java/konogonka/Workers/DumbRomFsExtractor.java index 9d7b2a2..58503ba 100644 --- a/src/main/java/konogonka/Workers/DumbRomFsExtractor.java +++ b/src/main/java/konogonka/Workers/DumbRomFsExtractor.java @@ -10,6 +10,7 @@ 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 { @@ -63,17 +64,17 @@ public class DumbRomFsExtractor extends Task { } 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(new FileOutputStream(contentFile)); + 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.getFileSize(); + long progressHandleFSize = entry.getSize(); int progressHandleFRead = 0; //*** PROGRESS BAR VARS END while ((readSize = pis.read(readBuf)) > -1) { diff --git a/src/main/resources/FXML/NCA/NCAFsHeaderBlock.fxml b/src/main/resources/FXML/NCA/NCAFsHeaderBlock.fxml index d46f0f5..47269e2 100644 --- a/src/main/resources/FXML/NCA/NCAFsHeaderBlock.fxml +++ b/src/main/resources/FXML/NCA/NCAFsHeaderBlock.fxml @@ -15,8 +15,8 @@ - - + + @@ -28,7 +28,7 @@ - + @@ -300,11 +300,11 @@ - + - + - + @@ -472,7 +472,7 @@ - + @@ -576,7 +576,7 @@ - + @@ -784,7 +784,7 @@ - + @@ -888,7 +888,7 @@ - + @@ -992,7 +992,7 @@ - + @@ -1091,7 +1091,7 @@ - + @@ -1165,11 +1165,11 @@ - + - + - + @@ -1299,9 +1299,6 @@ - - - - + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + @@ -1419,11 +1443,11 @@ - + - + - + + + + @@ -1941,16 +1968,16 @@ - + - + - + @@ -2053,7 +2080,7 @@ - + @@ -2149,7 +2176,7 @@ - + @@ -2222,6 +2249,9 @@ + + + @@ -2263,16 +2293,16 @@ - + - + - + @@ -2375,7 +2405,7 @@ - + @@ -2471,7 +2501,7 @@ - + @@ -2502,6 +2532,9 @@ + + + @@ -2517,16 +2550,16 @@ - + - + - + @@ -2623,12 +2656,12 @@ - + + + diff --git a/src/main/resources/FXML/NCA/NCASectionContent.fxml b/src/main/resources/FXML/NCA/NCASectionContent.fxml index 09ffcbc..d1fdb53 100644 --- a/src/main/resources/FXML/NCA/NCASectionContent.fxml +++ b/src/main/resources/FXML/NCA/NCASectionContent.fxml @@ -10,11 +10,11 @@ - + -