Uninstaller.java 1.38 KB
Newer Older
1 2 3 4
/**
 * $Revision: $
 * $Date:  $
 *
Matt Tucker's avatar
Matt Tucker committed
5
 * Copyright (C) 1999-2006 Jive Software. All rights reserved.
6 7 8 9
 *
 * This software is the proprietary information of Jive Software.
 * Use is subject to license terms.
 */
Matt Tucker's avatar
Matt Tucker committed
10

11
package org.jivesoftware.openfire.launcher;
12 13 14 15 16 17

import com.install4j.api.Context;
import com.install4j.api.ProgressInterface;
import com.install4j.api.UninstallAction;

import java.io.File;
Matt Tucker's avatar
Matt Tucker committed
18
import java.io.FilenameFilter;
19 20 21

/**
 * Used with the Install4J installer to uninstall the remaining files within
22
 * the Openfire install.
23 24 25 26 27 28 29 30 31 32 33 34
 */
public class Uninstaller extends UninstallAction {

    public int getPercentOfTotalInstallation() {
        return 0;
    }

    public boolean performAction(Context context, ProgressInterface progressInterface) {
        final File installationDirectory = context.getInstallationDirectory();

        File libDirectory = new File(installationDirectory, "lib");

Matt Tucker's avatar
Matt Tucker committed
35
        // If the directory still exists, remove all JAR files.
36
        if (libDirectory.exists() && libDirectory.isDirectory()) {
Matt Tucker's avatar
Matt Tucker committed
37 38 39 40 41 42 43
            File[] jars = libDirectory.listFiles(new FilenameFilter() {
                public boolean accept(File dir, String name) {
                    return name.endsWith(".jar");
                }
            });
            for (File jar : jars) {
                jar.delete();
44 45 46
            }
        }

Matt Tucker's avatar
Matt Tucker committed
47
        return super.performAction(context, progressInterface);
48 49
    }

Matt Tucker's avatar
Matt Tucker committed
50
}