package com.hibegin.http.server.util;

import java.io.File;

/**
 * 提供给一些路径供程序更方便的调用
 *
 * @author Chun
 */
public class PathUtil {

    private static String ROOT_PATH = "";

    public static String getConfPath() {
        return getRootPath() + "/conf/";
    }

    public static String getRootPath() {
        if (ROOT_PATH != null && ROOT_PATH.length() > 0) {
            return ROOT_PATH;
        } else {
            String path;
            if (PathUtil.class.getResource("/") != null) {
                path = new File(PathUtil.class.getClass().getResource("/").getPath()).getParentFile().getParentFile().toString();
            } else {
                if (PathUtil.class.getProtectionDomain() != null) {
                    String thisPath = PathUtil.class.getProtectionDomain().getCodeSource().getLocation().getPath().replace("\\", "/");
                    if ("/".equals(File.separator)) {
                        path = thisPath.substring(0, thisPath.lastIndexOf('/'));
                    } else {
                        path = thisPath.substring(1, thisPath.lastIndexOf('/'));
                    }
                } else {
                    path = "/";
                }
            }
            return path;
        }
    }

    public static void setRootPath(String rootPath) {
        ROOT_PATH = rootPath;
    }

    public static String getConfFile(String file) {
        return getConfPath() + file;
    }

    public static String getStaticPath() {
        return getRootPath() + "/static/";
    }

    public static String getTempPath() {
        String str = getRootPath() + "/temp/";
        new File(str).mkdirs();
        return str;
    }
}
@@ -421,813 +421,45 @@
     
-String path;%0A            if (PathUtil.class.getResource(%22/%22) != null) %7B%0A                path = new File(PathUtil.class.getClass().getResource(%22/%22).getPath()).getParentFile().getParentFile().toString();%0A            %7D else %7B%0A                if (PathUtil.class.getProtectionDomain() != null) %7B%0A                    String thisPath = PathUtil.class.getProtectionDomain().getCodeSource().getLocation().getPath().replace(%22%5C%5C%22, %22/%22);%0A                    if (%22/%22.equals(File.separator)) %7B%0A                        path = thisPath.substring(0, thisPath.lastIndexOf('/'));%0A                    %7D else %7B%0A                        path = thisPath.substring(1, thisPath.lastIndexOf('/'));%0A                    %7D%0A                %7D else %7B%0A                    path = %22/%22;%0A                %7D%0A            %7D%0A            return path
+return System.getProperty(%22user.dir%22)
 ;%0A  

fix get root path error(such chinese, space char)