|
|
@ -17,6 +17,7 @@ var DBRows *sql.Rows
|
|
|
|
var ShellRes, ShellErr string
|
|
|
|
var ShellRes, ShellErr string
|
|
|
|
var ShellExit bool
|
|
|
|
var ShellExit bool
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Exits返回指定文件夹/文件是否存在
|
|
|
|
func Exists(filepath string) bool {
|
|
|
|
func Exists(filepath string) bool {
|
|
|
|
_, err := os.Stat(filepath)
|
|
|
|
_, err := os.Stat(filepath)
|
|
|
|
if err != nil && os.IsNotExist(err) {
|
|
|
|
if err != nil && os.IsNotExist(err) {
|
|
|
@ -24,6 +25,9 @@ func Exists(filepath string) bool {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//IsFile返回给定文件地址是否是一个文件,
|
|
|
|
|
|
|
|
//True为是一个文件,False为不是文件或路径无效
|
|
|
|
func IsFile(fpath string) bool {
|
|
|
|
func IsFile(fpath string) bool {
|
|
|
|
s, err := os.Stat(fpath)
|
|
|
|
s, err := os.Stat(fpath)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
@ -31,6 +35,9 @@ func IsFile(fpath string) bool {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return !s.IsDir()
|
|
|
|
return !s.IsDir()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//IsFolder返回给定文件地址是否是一个文件夹,
|
|
|
|
|
|
|
|
//True为是一个文件夹,False为不是文件夹或路径无效
|
|
|
|
func IsFolder(fpath string) bool {
|
|
|
|
func IsFolder(fpath string) bool {
|
|
|
|
s, err := os.Stat(fpath)
|
|
|
|
s, err := os.Stat(fpath)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
@ -39,15 +46,19 @@ func IsFolder(fpath string) bool {
|
|
|
|
return s.IsDir()
|
|
|
|
return s.IsDir()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//CurlGet发起一个HTTP GET请求
|
|
|
|
func CurlGet(url string) (error, []byte) {
|
|
|
|
func CurlGet(url string) (error, []byte) {
|
|
|
|
err, _, res, _, _ := Curl(url, "", HttpNul, HttpNul2, "GET")
|
|
|
|
err, _, res, _, _ := Curl(url, "", HttpNul, HttpNul2, "GET")
|
|
|
|
return err, res
|
|
|
|
return err, res
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//CurlPost发起一个基于表单的HTTP Post请求
|
|
|
|
func CurlPost(url, postdata string) (error, []byte) {
|
|
|
|
func CurlPost(url, postdata string) (error, []byte) {
|
|
|
|
err, _, res, _, _ := Curl(url, postdata, HttpNul, HttpNul2, "POST")
|
|
|
|
err, _, res, _, _ := Curl(url, postdata, HttpNul, HttpNul2, "POST")
|
|
|
|
return err, res
|
|
|
|
return err, res
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//HttpNulReset将重置Header和Cookie为空
|
|
|
|
func HttpNulReset() {
|
|
|
|
func HttpNulReset() {
|
|
|
|
var tmp map[string]string
|
|
|
|
var tmp map[string]string
|
|
|
|
HttpNul, HttpNul2 = tmp, tmp
|
|
|
|
HttpNul, HttpNul2 = tmp, tmp
|
|
|
|