diff --git a/JUninstaller.java b/JUninstaller.java index 0a49e58..52c402a 100644 --- a/JUninstaller.java +++ b/JUninstaller.java @@ -72,11 +72,13 @@ public class JUninstaller extends Frame implements ActionListener { Label lbTime = new Label("--:--:--", Label.CENTER); Panel pnView = new Panel(new BorderLayout()); + Panel pnDel = new Panel(new BorderLayout()); Panel pnViewB = new Panel(new GridLayout(0,1,0,0)); Label lbView = new Label("---"); List ltView = new List(); Button btDetails = new Button("Details"); Button btRemove = new Button("Remove"); + Button btDelFile = new Button("Del"); Button btBack2 = new Button("Back"); Dimension dmScreen = Toolkit.getDefaultToolkit().getScreenSize(); // get Screen dimensions @@ -133,7 +135,7 @@ public class JUninstaller extends Frame implements ActionListener { } else { MIP.infoPrint("Can't delete!"); } - updateList(selItem+DATAEXT); + updateList(selItem); } } else { MIP.infoPrint("Select one entry!"); @@ -142,10 +144,12 @@ public class JUninstaller extends Frame implements ActionListener { clMain.show(pnMain, "1"); } else if (ae.getSource().equals(btScan)) { // Scan-Button parseFilesys(); + MQ.msgBox("Scan complete.", "Now install your desired application and RUN IT at least once.\n\nDO NOT INSTALL OR CHANGE ANYTHING ELSE.\n\nIf done, perform one of the two 'Find Changes'."); } else if (ae.getSource().equals(btFind)) { // Find changes-Button compareFilesys(false); } else if (ae.getSource().equals(btFUp)) { // Find changes + Update-Button compareFilesys(true); + MQ.msgBox("Log complete.", "You can now install+run the next application."); } else if (ae.getSource().equals(btUnin)) { // Uninstall-Button String selItem = ltApps.getSelectedItem(); if (selItem != null) { @@ -159,14 +163,7 @@ public class JUninstaller extends Frame implements ActionListener { String selItem = ltApps.getSelectedItem(); if (selItem != null) { lbView.setText("Details of "+selItem); - ltView.removeAll(); - MIP.busy("Reading..."); - String[] entries = mfs.getEntries(selItem+DATAEXT); - MIP.busy("Building list (" + entries.length + ")..."); - for (int i=0;i=0) { - selIdx = ltApps.getItemCount(); + if (selItem != null && apps[i].toLowerCase().compareTo(selItem)>=0) { + selIdx = ltApps.getItemCount()-1; selItem = null; } } - ltApps.select(selIdx); ltApps.makeVisible(selIdx); + ltApps.select(selIdx); } + private void updateDetList(String log, String selItem) { + ltView.removeAll(); + MIP.busy("Reading..."); + String[] entries = mfs.getEntries(log); + MIP.busy("Building list (" + entries.length + ")..."); + int selIdx = 0; + if (selItem!=null) selItem = selItem.substring(selItem.indexOf(" ")+1).toLowerCase(); + String cmpItem; + for (int i=0;i=0) { + selIdx = ltView.getItemCount()-1; + selItem = null; + } + } + ltView.makeVisible(selIdx); + ltView.select(selIdx); + MIP.infoPrint(entries.length+" entries"); + } + private void compareFilesys(boolean redump) { // parse filsystem and compare with // previously generated info @@ -381,7 +430,7 @@ public class JUninstaller extends Frame implements ActionListener { MIP.infoPrint("Could not delete!"); } } - updateList(newname+DATAEXT); + updateList(newname); clMain.show(pnMain, "1"); } else { MIP.infoPrint("No diffs found."); diff --git a/MyFilesystemParser.java b/MyFilesystemParser.java index 87a961e..32d8016 100644 --- a/MyFilesystemParser.java +++ b/MyFilesystemParser.java @@ -1,10 +1,12 @@ import java.io.BufferedOutputStream; import java.io.BufferedReader; +import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.io.IOException; +import java.io.OutputStreamWriter; import java.util.Calendar; import java.util.Date; @@ -250,6 +252,39 @@ public class MyFilesystemParser { return dumpDifferences(outfile, false); } + /** Removes a line from a log, doesn't touch the file on disk */ + public boolean removeLine(String infile, String filename) { + try { + BufferedWriter tout = new BufferedWriter(new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream("$$mfs$$.$$$")))); + BufferedReader fin = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(infile)))); + String tmp; + int tab; + String myfn; + while ((tmp = fin.readLine()) != null) { + tab = tmp.indexOf("\t"); + myfn = tmp.substring(tab+1, tmp.indexOf("\t", tab+1)); + if (!myfn.equals(filename)) tout.write(tmp+"\r\n"); + } + tout.close(); + fin.close(); + File oldlog = new File(infile); + File newlog = new File("$$mfs$$.$$$"); + if (oldlog.delete()) { + if (!newlog.renameTo(oldlog)) { + System.out.println("ERROR: Could not rename new log to "+logFile.getName()+"."); + return false; + } + } else { + System.out.println("ERROR: Could not delete old logfile. Redump is still there."); + return false; + } + return true; + } catch (IOException ioe) { + ioe.printStackTrace(); + return false; + } + } + /** Deletes dump */ public boolean delDump() { return logFile.delete();