Uninstaller.java 1.52 KB
Newer Older
1
/**
2 3 4
 * $RCSfile$
 * $Revision: 3144 $
 * $Date: 2005-12-01 14:20:11 -0300 (Thu, 01 Dec 2005) $
5
 *
6
 * Copyright (C) 2004-2008 Jive Software. All rights reserved.
7
 *
8 9 10
 * This software is published under the terms of the GNU Public License (GPL),
 * a copy of which is included in this distribution, or a commercial license
 * agreement with Jive.
11
 */
Matt Tucker's avatar
Matt Tucker committed
12

13
package org.jivesoftware.openfire.launcher;
14 15 16 17 18 19

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
20
import java.io.FilenameFilter;
21 22 23

/**
 * Used with the Install4J installer to uninstall the remaining files within
24
 * the Openfire install.
25 26 27 28 29 30 31 32 33 34 35 36
 */
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
37
        // If the directory still exists, remove all JAR files.
38
        if (libDirectory.exists() && libDirectory.isDirectory()) {
Matt Tucker's avatar
Matt Tucker committed
39 40 41 42 43 44 45
            File[] jars = libDirectory.listFiles(new FilenameFilter() {
                public boolean accept(File dir, String name) {
                    return name.endsWith(".jar");
                }
            });
            for (File jar : jars) {
                jar.delete();
46 47 48
            }
        }

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

Matt Tucker's avatar
Matt Tucker committed
52
}