package com.ruoyi.xq.util;

import org.springframework.util.ResourceUtils;

import java.io.File;
import java.io.FileNotFoundException;

public class FileUtils {

    private final static String TEMP_PATH = "/temp";

    public static String getTempFile() throws FileNotFoundException {
        File path = new File(ResourceUtils.getURL("classpath:").getPath());
        if (!path.exists()) {
            path = new File("");
        }
        File tempLocaltion = new File(path.getAbsolutePath() + TEMP_PATH);
        if (!tempLocaltion.exists()) {
            tempLocaltion.mkdirs();
        }
        return tempLocaltion.getAbsolutePath();
    }

    public static String getRootFIle() throws FileNotFoundException {
        File path = new File(ResourceUtils.getURL("classpath:").getPath());
        if (!path.exists()) {
            path = new File("");
        }
        return path.getAbsolutePath();
    }
}
