XML support [basic]
This commit is contained in:
parent
37014aaf7f
commit
02b49d9cb2
12 changed files with 129 additions and 24 deletions
|
@ -20,3 +20,9 @@ Deep WIP multi-tool to work with XCI/NSP/NCA/NRO(?) files
|
|||
### System requirements
|
||||
|
||||
JRE/JDK 8u60 or higher.
|
||||
|
||||
### Checklist
|
||||
|
||||
* [ ] LogPrinter to singleton implementation
|
||||
* [ ] CNMT support
|
||||
* [ ] support
|
|
@ -6,8 +6,8 @@ import javafx.scene.Scene;
|
|||
import javafx.scene.image.Image;
|
||||
import javafx.stage.Stage;
|
||||
import konogonka.Controllers.IRowModel;
|
||||
import konogonka.Controllers.NCA.NCAController;
|
||||
import konogonka.Controllers.TIK.TIKController;
|
||||
import konogonka.Controllers.ITabController;
|
||||
import konogonka.Controllers.XML.XMLController;
|
||||
import konogonka.Tools.ISuperProvider;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -29,19 +29,18 @@ public class ChildWindow {
|
|||
else if(model.getFileName().endsWith(".tik")){
|
||||
loaderSettings = new FXMLLoader(getClass().getResource("/FXML/TIK/TIKTab.fxml"));
|
||||
}
|
||||
else if(model.getFileName().endsWith(".xml")){
|
||||
loaderSettings = new FXMLLoader(getClass().getResource("/FXML/XML/XMLTab.fxml"));
|
||||
}
|
||||
else if(model.getFileName().endsWith(".cert")){
|
||||
// TODO: IMPLEMENT
|
||||
return;
|
||||
}
|
||||
else if(model.getFileName().endsWith(".tik")){
|
||||
else if(model.getFileName().endsWith(".cnmt")){
|
||||
// TODO: IMPLEMENT
|
||||
return;
|
||||
}
|
||||
else if(model.getFileName().endsWith(".xml")){
|
||||
// TODO: IMPLEMENT
|
||||
return;
|
||||
}
|
||||
else
|
||||
else // TODO: Dynamic detection function
|
||||
return;
|
||||
|
||||
Locale userLocale = new Locale(Locale.getDefault().getISO3Language());
|
||||
|
@ -49,15 +48,14 @@ public class ChildWindow {
|
|||
loaderSettings.setResources(resourceBundle);
|
||||
Parent parentAbout = loaderSettings.load();
|
||||
|
||||
|
||||
// TODO: REFACTOR
|
||||
if (model.getFileName().endsWith(".nca")){
|
||||
NCAController ncaController = loaderSettings.<NCAController>getController();
|
||||
ncaController.analyze(provider.getFile(), provider.getRawFileDataStart()+model.getFileOffset());
|
||||
// TODO: fix?
|
||||
if(model.getFileName().endsWith(".xml")){
|
||||
XMLController myController = loaderSettings.<XMLController>getController();
|
||||
myController.analyze(provider.getFile(), provider.getRawFileDataStart()+model.getFileOffset(), model.getFileSize());
|
||||
}
|
||||
else if(model.getFileName().endsWith(".tik")){
|
||||
TIKController tikController = loaderSettings.<TIKController>getController();
|
||||
tikController.analyze(provider.getFile(), provider.getRawFileDataStart()+model.getFileOffset());
|
||||
else {
|
||||
ITabController myController = loaderSettings.<ITabController>getController();
|
||||
myController.analyze(provider.getFile(), provider.getRawFileDataStart()+model.getFileOffset());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import konogonka.Controllers.NCA.NCAController;
|
|||
import konogonka.Controllers.NSP.NSPController;
|
||||
import konogonka.Controllers.TIK.TIKController;
|
||||
import konogonka.Controllers.XCI.XCIController;
|
||||
import konogonka.Controllers.XML.XMLController;
|
||||
import konogonka.MediatorControl;
|
||||
import konogonka.Settings.SettingsWindow;
|
||||
import konogonka.Tools.ISuperProvider;
|
||||
|
@ -47,6 +48,8 @@ public class MainController implements Initializable {
|
|||
private NCAController NCATabController;
|
||||
@FXML
|
||||
private TIKController TIKTabController;
|
||||
@FXML
|
||||
private XMLController XMLTabController;
|
||||
|
||||
private File selectedFile;
|
||||
|
||||
|
@ -80,7 +83,7 @@ public class MainController implements Initializable {
|
|||
else
|
||||
fileChooser.setInitialDirectory(new File(System.getProperty("user.home")));
|
||||
|
||||
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("NS files", "*.nsp", "*.xci", "*.nca", "*.tik"));
|
||||
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("NS files", "*.nsp", "*.xci", "*.nca", "*.tik", "*.xml"));
|
||||
|
||||
this.selectedFile = fileChooser.showOpenDialog(analyzeBtn.getScene().getWindow());
|
||||
|
||||
|
@ -89,6 +92,7 @@ public class MainController implements Initializable {
|
|||
XCITabController.resetTab();
|
||||
NCATabController.resetTab();
|
||||
TIKTabController.resetTab();
|
||||
XMLTabController.resetTab();
|
||||
|
||||
if (this.selectedFile != null && this.selectedFile.exists()) {
|
||||
filenameSelected.setText(this.selectedFile.getAbsolutePath());
|
||||
|
@ -102,6 +106,8 @@ public class MainController implements Initializable {
|
|||
tabPane.getSelectionModel().select(2);
|
||||
else if (this.selectedFile.getName().toLowerCase().endsWith(".tik"))
|
||||
tabPane.getSelectionModel().select(3);
|
||||
else if (this.selectedFile.getName().toLowerCase().endsWith(".xml"))
|
||||
tabPane.getSelectionModel().select(4);
|
||||
}
|
||||
|
||||
logArea.clear();
|
||||
|
@ -118,6 +124,8 @@ public class MainController implements Initializable {
|
|||
NCATabController.analyze(selectedFile);
|
||||
else if (selectedFile.getName().toLowerCase().endsWith("tik"))
|
||||
TIKTabController.analyze(selectedFile);
|
||||
else if (selectedFile.getName().toLowerCase().endsWith("xml"))
|
||||
XMLTabController.analyze(selectedFile);
|
||||
}
|
||||
@FXML
|
||||
private void showHideLogs(){
|
||||
|
|
|
@ -94,7 +94,7 @@ public class NSPController implements ITabController {
|
|||
* */
|
||||
@Override
|
||||
public void analyze(File selectedFile, long offset){
|
||||
// TODO: IMPLEMENT
|
||||
// TODO: IMPLEMENT?
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
|
|
|
@ -6,7 +6,6 @@ import javafx.scene.control.Label;
|
|||
import javafx.scene.control.TextField;
|
||||
import konogonka.AppPreferences;
|
||||
import konogonka.Controllers.ITabController;
|
||||
import konogonka.MediatorControl;
|
||||
import konogonka.Tools.TIK.TIKProvider;
|
||||
import konogonka.Workers.AnalyzerTIK;
|
||||
|
||||
|
|
75
src/main/java/konogonka/Controllers/XML/XMLController.java
Normal file
75
src/main/java/konogonka/Controllers/XML/XMLController.java
Normal file
|
@ -0,0 +1,75 @@
|
|||
package konogonka.Controllers.XML;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.TextArea;
|
||||
import konogonka.Controllers.ITabController;
|
||||
import konogonka.MediatorControl;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class XMLController implements ITabController {
|
||||
@FXML
|
||||
|
||||
private TextArea mainTa;
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle resourceBundle) { }
|
||||
|
||||
/**
|
||||
* Read from start to end
|
||||
* */
|
||||
@Override
|
||||
public void analyze(File file) { analyze(file, 0); }
|
||||
/**
|
||||
* Read from offset to end
|
||||
* */
|
||||
@Override
|
||||
public void analyze(File file, long offset) {
|
||||
try {
|
||||
if (file.length() - offset > 10485760) // 10mB
|
||||
throw new Exception("XMLController -> analyze(): File is too big. It must be something wrong with it. Usually they're smaller");
|
||||
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
|
||||
if (bis.skip(offset) != offset)
|
||||
throw new Exception("XMLController -> analyze(): Unable to skip requested range");
|
||||
int readChunk = (int) (file.length() - offset);
|
||||
byte[] buffer = new byte[readChunk]; // Let it be 1kB
|
||||
if (bis.read(buffer) != readChunk)
|
||||
throw new Exception("XMLController -> analyze(): Unable to read requested range");
|
||||
mainTa.appendText(new String(buffer, 0, readChunk, StandardCharsets.UTF_8));
|
||||
bis.close();
|
||||
}
|
||||
catch (Exception e){
|
||||
MediatorControl.getInstance().getContoller().logArea.appendText("XMLController -> analyze(): \n"+e.getMessage());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Read from offset to length
|
||||
* */
|
||||
public void analyze(File file, long offset, long fileSize) {
|
||||
System.out.println(file.length()+" "+offset+" "+fileSize);
|
||||
try {
|
||||
if (fileSize > 10485760) // 10mB
|
||||
throw new Exception("XMLController -> analyze(): File is too big. It must be something wrong with it. Usually they're smaller");
|
||||
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
|
||||
if (bis.skip(offset) != offset)
|
||||
throw new Exception("XMLController -> analyze(): Unable to skip requested range");
|
||||
byte[] buffer = new byte[(int)fileSize]; // Let it be 1kB
|
||||
if (bis.read(buffer) != fileSize)
|
||||
throw new Exception("XMLController -> analyze(): Unable to read requested range");
|
||||
mainTa.appendText(new String(buffer, 0, (int) fileSize, StandardCharsets.UTF_8));
|
||||
bis.close();
|
||||
}
|
||||
catch (Exception e){
|
||||
MediatorControl.getInstance().getContoller().logArea.appendText("XMLController -> analyze(): \n"+e.getMessage());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void resetTab() {
|
||||
mainTa.setText(null);
|
||||
}
|
||||
}
|
11
src/main/resources/FXML/XML/XMLTab.fxml
Normal file
11
src/main/resources/FXML/XML/XMLTab.fxml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.TextArea?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
|
||||
|
||||
<AnchorPane xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="konogonka.Controllers.XML.XMLController">
|
||||
<children>
|
||||
<TextArea fx:id="mainTa" editable="false" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
|
@ -79,6 +79,14 @@
|
|||
<Label text="TIK" />
|
||||
</graphic>
|
||||
</Tab>
|
||||
<Tab closable="false">
|
||||
<content>
|
||||
<fx:include fx:id="XMLTab" source="XML/XMLTab.fxml" />
|
||||
</content>
|
||||
<graphic>
|
||||
<Label text="XML" />
|
||||
</graphic>
|
||||
</Tab>
|
||||
</tabs>
|
||||
</TabPane>
|
||||
<AnchorPane fx:id="logPane" prefHeight="200.0" prefWidth="200.0">
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
btnFileOpen=Select NSP/XCI/NCA/TIK
|
||||
btnFileOpen=Select NSP/XCI/NCA/TIK/XML
|
||||
btnAnalyze=Analyze
|
||||
lblNoFileSelected=No files selected.
|
||||
tableNumberLbl=#
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
btnFileOpen=Selectionner NSP/XCI/NCA/TIK
|
||||
btnFileOpen=Selectionner NSP/XCI/NCA/TIK/XML
|
||||
btnAnalyze=Analyser
|
||||
lblNoFileSelected=Aucuns fichiers s\u00E9lectionn\u00E9s.
|
||||
tableUploadLbl=Extraire ?
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
btnFileOpen=\u0412\u044B\u0431\u0440\u0430\u0442\u044C NSP/XCI/NCA/TIK
|
||||
btnFileOpen=\u0412\u044B\u0431\u0440\u0430\u0442\u044C NSP/XCI/NCA/TIK/XML
|
||||
btnAnalyze=\u0410\u043D\u0430\u043B\u0438\u0437\u0438\u0440\u043E\u0432\u0430\u0442\u044C
|
||||
lblNoFileSelected=\u0424\u0430\u0439\u043B\u044B \u043D\u0435 \u0432\u044B\u0431\u0440\u0430\u043D\u044B.
|
||||
tableUploadLbl=\u0420\u0430\u0441\u043F\u0430\u043A\u043E\u0432\u0430\u0442\u044C?
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
btnFileOpen=\u0412\u0438\u0431\u0440\u0430\u0442\u0438 NSP/XCI/NCA/TIK
|
||||
btnFileOpen=\u0412\u0438\u0431\u0440\u0430\u0442\u0438 NSP/XCI/NCA/TIK/XML
|
||||
btnAnalyze=\u0410\u043D\u0430\u043B\u0456\u0437\u0443\u0432\u0430\u0442\u0438
|
||||
lblNoFileSelected=\u0424\u0430\u0439\u043B\u0438 \u043D\u0435 \u0432\u0438\u0431\u0440\u0430\u043D\u0456.
|
||||
tableNumberLbl=\u2116
|
||||
|
|
Loading…
Reference in a new issue