FileUtils.java 988 Bytes
package com.polysoft.nafmii.utils;

import java.io.File;

public class FileUtils {

    public static File getIndex() {
        return new File(getDistDir(), "index.html");
    }

    public static File getDistDir() {
        File dist = new File(getRootDir(), "dist");
        if (!dist.exists()) {
            dist.mkdirs();
        }
        return dist;
    }

    public static File getDownloadDir() {
        File download = new File(getRootDir(), "download");
        if (!download.exists()) {
            download.mkdirs();
        }
        return download;
    }

    public static File getRootDir() {
        return CtxUtils.getApplication().getFilesDir();
    }

    public static File getRootCacheDir() {
        return CtxUtils.getApplication().getCacheDir();
    }

    public static void deletes(File file) {
        if (file.isDirectory()) {
            for (File f : file.listFiles()) {
                deletes(f);
            }
        }
        file.delete();
    }
}