2019-04-07 04:25:07 +00:00
|
|
|
package utils
|
|
|
|
|
2020-03-31 07:19:57 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
2020-05-11 03:35:45 +00:00
|
|
|
"io/ioutil"
|
2020-03-31 07:19:57 +00:00
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"strings"
|
|
|
|
)
|
2019-04-07 04:25:07 +00:00
|
|
|
|
|
|
|
func ByteSliceToString(b []byte) string {
|
|
|
|
var ret string
|
|
|
|
|
|
|
|
for i := 0; i < len(b); i++ {
|
|
|
|
s := fmt.Sprintf("%02x", b[i])
|
|
|
|
ret += string(s)
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|
2020-03-31 07:19:57 +00:00
|
|
|
func GetCurrentDirectory() string {
|
|
|
|
dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
|
|
|
|
if err != nil {
|
|
|
|
return "./"
|
|
|
|
}
|
|
|
|
return strings.Replace(dir, "\\", "/", -1)
|
|
|
|
}
|
2020-05-11 03:35:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
func GetPathFileName(pathname string) (error) {
|
|
|
|
rd, err := ioutil.ReadDir(pathname)
|
|
|
|
for _, fi := range rd {
|
|
|
|
if fi.IsDir() {
|
|
|
|
fmt.Printf("[%s]\n", pathname+"\\"+fi.Name())
|
|
|
|
GetPathFileName(pathname + fi.Name() + "\\")
|
|
|
|
} else {
|
|
|
|
fmt.Println(fi.Name())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|