version 0.1.0

This commit is contained in:
ᴍᴏᴏɴD4ʀᴋ
2020-06-28 17:18:02 +08:00
parent 9960f402bc
commit ecc1665912
7 changed files with 272 additions and 99 deletions
+38 -2
View File
@@ -14,6 +14,9 @@ import (
var (
passwordIsEmpty = errors.New("decrypt fail, password is empty")
errBrowserNotSupported = errors.New("browser not supported")
VersionUnder80 bool
)
type DecryptError struct {
@@ -29,6 +32,11 @@ func (e *DecryptError) Unwrap() error {
return e.err
}
type Browser struct {
Name string
DataDir string
}
const (
LoginData = "Login Data"
History = "History"
@@ -36,6 +44,29 @@ const (
Bookmarks = "Bookmarks"
)
func ListBrowser() []string {
var l []string
for k := range browserList {
l = append(l, k)
}
return l
}
func GetDBPath(dir string, dbName ...string) (dbFile []string) {
for _, v := range dbName {
s, err := filepath.Glob(dir + v)
if err != nil && len(s) == 0 {
continue
}
if len(s) > 0 {
log.Debugf("Find %s File Success", v)
log.Debugf("%s file location is %s", v, s[0])
dbFile = append(dbFile, s[0])
}
}
return dbFile
}
func CopyDB(src, dst string) error {
locals, _ := filepath.Glob("*")
for _, v := range locals {
@@ -65,6 +96,11 @@ func IntToBool(a int) bool {
return true
}
func TimeStampFormat(stamp int64) time.Time {
s1 := time.Unix(stamp, 0)
return s1
}
func TimeEpochFormat(epoch int64) time.Time {
maxTime := int64(99633311740000000)
if epoch > maxTime {
@@ -101,9 +137,9 @@ func WriteFile(filename string, data []byte) error {
return err
}
func FormatFileName(dir, filename, format string) string {
func FormatFileName(dir, browser, filename, format string) string {
r := strings.TrimSpace(strings.ToLower(filename))
p := path.Join(dir, fmt.Sprintf("%s.%s", r, format))
p := path.Join(dir, fmt.Sprintf("%s_%s.%s", r, browser, format))
return p
}