Ver código fonte

removing pkg

Wilfried Klaas 2 anos atrás
pai
commit
135cf68514
2 arquivos alterados com 58 adições e 1 exclusões
  1. 0 1
      .gitignore
  2. 58 0
      pkg/hash/hash.go

+ 0 - 1
.gitignore

@@ -1,6 +1,5 @@
 
 *.exe
-pkg
 src/github.com
 __debug_bin
 report.txt

+ 58 - 0
pkg/hash/hash.go

@@ -0,0 +1,58 @@
+package hash
+
+import (
+	"encoding/json"
+	"io/ioutil"
+	"path/filepath"
+	"time"
+)
+
+// Fdhashes struct for holding all informations about one folder.
+type Fdhashes struct {
+	Path   string
+	Hashes map[string]string
+	Times  map[string]time.Time
+	Dirty  bool
+}
+
+func LoadHashfile(fileStr string) (*Fdhashes, error) {
+	dir, _ := filepath.Split(fileStr)
+	dir = filepath.ToSlash(filepath.Clean(dir))
+	var data Fdhashes
+	file, err := ioutil.ReadFile(fileStr)
+	if err != nil {
+		return nil, err
+	}
+	err = json.Unmarshal([]byte(file), &data)
+	if err != nil {
+		return nil, err
+	}
+	if data.Path != dir {
+		data.Path = dir
+		data.Dirty = true
+	}
+	return &data, nil
+}
+
+/*
+func LoadHashfile(fileStr string) Fdhashes {
+	dir, _ := filepath.Split(fileStr)
+	dir = filepath.ToSlash(filepath.Clean(dir))
+	data := Fdhashes{Path: dir, Hashes: make(map[string]string), Times: make(map[string]time.Time), Dirty: false}
+	if !rewrite {
+		file, err := ioutil.ReadFile(fileStr)
+		if err != nil {
+			panic(err)
+		}
+		err = json.Unmarshal([]byte(file), &data)
+		if err != nil {
+			log.Printf("can't read file %s", fileStr)
+		}
+	}
+	if data.Path != dir {
+		data.Path = dir
+		data.Dirty = true
+	}
+	return data
+}
+*/