From f3bcb356ea0e74c5b63b4c537dffa34eec42b3e3 Mon Sep 17 00:00:00 2001 From: Dmitry Isaenko Date: Mon, 27 Apr 2020 05:24:17 +0300 Subject: [PATCH] Extract files support for 'RomFS' content (decrypted blob) --- .../Controllers/NSP/NSPController.java | 6 +- .../RFS/RFSFolderTableViewController.java | 74 ++++++----- .../RFS/{RFSEntry.java => RFSModelEntry.java} | 8 +- .../Controllers/RFS/RomFsController.java | 117 +++++++++++++++--- .../Tools/RomFs/FileSystemEntry.java | 2 +- .../konogonka/Tools/RomFs/IRomFsProvider.java | 30 +++++ .../Tools/RomFs/RomFsDecryptedProvider.java | 80 +++++++----- src/main/java/konogonka/Workers/Analyzer.java | 20 +++ .../Workers/DumbNCA3ContentExtractor.java | 2 +- .../konogonka/Workers/DumbRomFsExtractor.java | 109 ++++++++++++++++ .../java/konogonka/Workers/Extractor.java | 2 +- src/main/resources/FXML/RomFS/RFSTab.fxml | 20 +++ 12 files changed, 385 insertions(+), 85 deletions(-) rename src/main/java/konogonka/Controllers/RFS/{RFSEntry.java => RFSModelEntry.java} (89%) create mode 100644 src/main/java/konogonka/Tools/RomFs/IRomFsProvider.java create mode 100644 src/main/java/konogonka/Workers/DumbRomFsExtractor.java diff --git a/src/main/java/konogonka/Controllers/NSP/NSPController.java b/src/main/java/konogonka/Controllers/NSP/NSPController.java index 68ba8a2..ad44acf 100644 --- a/src/main/java/konogonka/Controllers/NSP/NSPController.java +++ b/src/main/java/konogonka/Controllers/NSP/NSPController.java @@ -112,13 +112,13 @@ public class NSPController implements ITabController { @Override public void analyze(File selectedFile, long offset){ // TODO: IMPLEMENT?? - return; + System.out.print("NOT IMPLEMENTED: NSPController -> analyze(File selectedFile, long offset)"); } @Override public void analyze(File selectedFile){ - Task analyzer = Analyzer.analyzePFS0(selectedFile); + Task analyzer = Analyzer.analyzePFS0(selectedFile); analyzer.setOnSucceeded(e->{ - PFS0Provider pfs0 = (PFS0Provider) analyzer.getValue(); + PFS0Provider pfs0 = analyzer.getValue(); this.setData(pfs0, selectedFile); }); Thread workThread = new Thread(analyzer); diff --git a/src/main/java/konogonka/Controllers/RFS/RFSFolderTableViewController.java b/src/main/java/konogonka/Controllers/RFS/RFSFolderTableViewController.java index ffe9aac..fcfdfe0 100644 --- a/src/main/java/konogonka/Controllers/RFS/RFSFolderTableViewController.java +++ b/src/main/java/konogonka/Controllers/RFS/RFSFolderTableViewController.java @@ -19,8 +19,6 @@ package konogonka.Controllers.RFS; import javafx.beans.InvalidationListener; -import javafx.beans.Observable; -import javafx.beans.binding.Bindings; import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; @@ -36,15 +34,15 @@ import javafx.scene.input.KeyCode; import javafx.scene.input.MouseButton; import javafx.scene.layout.HBox; import javafx.scene.layout.Region; -import konogonka.Controllers.IRowModel; +import konogonka.Tools.RomFs.FileSystemEntry; import java.net.URL; import java.util.*; public class RFSFolderTableViewController implements Initializable { @FXML - private TableView table; - private ObservableList rowsObsLst; + private TableView table; + private ObservableList rowsObsLst; @FXML private HBox navigationHBox; @@ -59,7 +57,7 @@ public class RFSFolderTableViewController implements Initializable { table.setOnKeyPressed(keyEvent -> { if (!rowsObsLst.isEmpty()) { if (keyEvent.getCode() == KeyCode.SPACE) { - for (RFSEntry item : table.getSelectionModel().getSelectedItems()) { + for (RFSModelEntry item : table.getSelectionModel().getSelectedItems()) { item.setMarkSelected( ! item.isMarkSelected()); } table.refresh(); @@ -68,11 +66,11 @@ public class RFSFolderTableViewController implements Initializable { keyEvent.consume(); }); - TableColumn imageColumn = new TableColumn<>(); - TableColumn fileNameColumn = new TableColumn<>(resourceBundle.getString("tableFileNameLbl")); - TableColumn fileOffsetColumn = new TableColumn<>(resourceBundle.getString("tableOffsetLbl")); - TableColumn fileSizeColumn = new TableColumn<>(resourceBundle.getString("tableSizeLbl")); - TableColumn checkBoxColumn = new TableColumn<>(resourceBundle.getString("tableUploadLbl")); + TableColumn imageColumn = new TableColumn<>(); + TableColumn fileNameColumn = new TableColumn<>(resourceBundle.getString("tableFileNameLbl")); + TableColumn fileOffsetColumn = new TableColumn<>(resourceBundle.getString("tableOffsetLbl")); + TableColumn fileSizeColumn = new TableColumn<>(resourceBundle.getString("tableSizeLbl")); + TableColumn checkBoxColumn = new TableColumn<>(resourceBundle.getString("tableUploadLbl")); imageColumn.setEditable(false); fileNameColumn.setEditable(false); @@ -104,7 +102,7 @@ public class RFSFolderTableViewController implements Initializable { checkBoxColumn.setResizable(false); imageColumn.setCellValueFactory(paramFeatures -> { - RFSEntry model = paramFeatures.getValue(); + RFSModelEntry model = paramFeatures.getValue(); return new ObservableValue() { @Override public Node getValue() { @@ -130,7 +128,7 @@ public class RFSFolderTableViewController implements Initializable { fileSizeColumn.setCellValueFactory(new PropertyValueFactory<>("fileSize")); fileOffsetColumn.setCellValueFactory(new PropertyValueFactory<>("fileOffset")); checkBoxColumn.setCellValueFactory(paramFeatures -> { - RFSEntry model = paramFeatures.getValue(); + RFSModelEntry model = paramFeatures.getValue(); SimpleBooleanProperty booleanProperty = new SimpleBooleanProperty(model.isMarkSelected()); @@ -144,30 +142,30 @@ public class RFSFolderTableViewController implements Initializable { checkBoxColumn.setCellFactory(paramFeatures -> new CheckBoxTableCell<>()); table.setRowFactory( // this shit is made to implement context menu. It's such a pain.. RFSEntryTableView -> { - final TableRow row = new TableRow<>(); + final TableRow row = new TableRow<>(); + /* ContextMenu contextMenu = new ContextMenu(); - /* // TODO: CHANGE TO 'Export' or something - MenuItem openMenuItem = new MenuItem("Open"); - openMenuItem.setOnAction(new EventHandler() { - @Override - public void handle(ActionEvent actionEvent) { - MediatorControl.getInstance().getContoller().showContentWindow(provider, row.getItem()); - } + // TODO: ADD'Export'? + MenuItem openMenuItem = new MenuItem("Export"); + openMenuItem.setOnAction(event -> { + RFSEntry entry = row.getItem(); + System.out.print("Selected: "+entry.getFileName()); }); - contextMenu.getItems().addAll(openMenuItem); - */ + contextMenu.getItems().add(openMenuItem); row.setContextMenu(contextMenu); + row.contextMenuProperty().bind( Bindings.when(Bindings.isNotNull(row.itemProperty())).then(contextMenu).otherwise((ContextMenu)null) ); - // Just.. don't ask.. + */ row.setOnMouseClicked(mouseEvent -> { if (!row.isEmpty() && mouseEvent.getButton() == MouseButton.PRIMARY){ - RFSEntry thisItem = row.getItem(); + RFSModelEntry thisItem = row.getItem(); thisItem.setMarkSelected(!thisItem.isMarkSelected()); table.refresh(); } + mouseEvent.consume(); }); return row; @@ -180,10 +178,11 @@ public class RFSFolderTableViewController implements Initializable { table.getColumns().add(fileSizeColumn); table.getColumns().add(checkBoxColumn); } + /** * Add files when user selected them on left-hand tree * */ - public void setContent(TreeItem containerTreeItem){ + public void setContent(TreeItem containerTreeItem){ reset(); if (containerTreeItem == null) { @@ -191,7 +190,7 @@ public class RFSFolderTableViewController implements Initializable { return; } - for (TreeItem childTreeItem : containerTreeItem.getChildren()) + for (TreeItem childTreeItem : containerTreeItem.getChildren()) rowsObsLst.add(childTreeItem.getValue()); setNavigationContent(containerTreeItem); @@ -199,8 +198,8 @@ public class RFSFolderTableViewController implements Initializable { table.refresh(); } - private void setNavigationContent(TreeItem childTreeItem){ - TreeItem parentTreeItem; + private void setNavigationContent(TreeItem childTreeItem){ + TreeItem parentTreeItem; LinkedList + + + + + +