func RealPath(path string, addSlash ...bool) (realPath string) {
	if len(path) == 0 || (path[0] != '/' && !filepath.IsAbs(path)) {
		path = ProjectPath + "/" + path
	}
	realPath, _ = filepath.Abs(path)
	realPath = strings.Replace(realPath, "\\", "/", -1)
	realPath = pathAddSlash(realPath, addSlash...)
	return
}
RealPath get an absolute path
package zfile
import (
	"fmt"
	"io"
	"io/ioutil"
	"math"
	"os"
	"path/filepath"
	"strings"
)
var (
	ProjectPath = "."
)
func init() {
	ProjectPath = ProgramPath()
	if strings.Contains(ProjectPath, TmpPath("")) {
		ProjectPath = RootPath()
	}
}
func PathExist(path string) (int, error) {
	path = RealPath(path)
	f, err := os.Stat(path)
	if err == nil {
		isFile := 2
		if f.IsDir() {
			isFile = 1
		}
		return isFile, nil
	}
	return 0, err
}
func DirExist(path string) bool {
	state, _ := PathExist(path)
	return state == 1
}
func FileExist(path string) bool {
	state, _ := PathExist(path)
	return state == 2
}
func FileSize(file string) (size string) {
	file = RealPath(file)
	fileInfo, err := os.Stat(file)
	if err != nil {
		size = SizeFormat(0)
	} else {
		size = SizeFormat(uint64(fileInfo.Size()))
	}
	return
}
func SizeFormat(s uint64) string {
	sizes := []string{"B", "KB", "MB", "GB", "TB", "PB", "EB"}
	humanateBytes := func(s uint64, base float64, sizes []string) string {
		if s < 10 {
			return fmt.Sprintf("%d B", s)
		}
		e := math.Floor(logSize(float64(s), base))
		suffix := sizes[int(e)]
		val := float64(s) / math.Pow(base, math.Floor(e))
		f := "%.0f"
		if val < 10 {
			f = "%.1f"
		}
		return fmt.Sprintf(f+" %s", val, suffix)
	}
	return humanateBytes(s, 1024, sizes)
}
func logSize(n, b float64) float64 {
	return math.Log(n) / math.Log(b)
}
func RootPath() string {
	path, _ := filepath.Abs(".")
	return RealPath(path, true)
}
func TmpPath(pattern ...string) string {
	p := ""
	if len(pattern) > 0 {
		p = pattern[0]
	}
	path, _ := ioutil.TempDir("", p)
	if p == "" {
		path, _ = filepath.Split(path)
	}
	path, _ = filepath.EvalSymlinks(path)
	return RealPath(path)
}
func SafePath(path string, pathRange ...string) string {
	base := ""
	if len(pathRange) == 0 {
		base = RootPath()
	} else {
		base = RealPath(pathRange[0], true)
	}
	return strings.TrimPrefix(RealPath(path, true), base)
}