mirror of
https://github.com/JaCoB1123/dupe-finder.git
synced 2026-11-12 23:11:02 +01:00
Extract filesmap to own file
This commit is contained in:
1 parent
8a9bcbf62e
commit
87c8a6e817
3 files changed
+85
-82
No files matched your search
@@ -1,6 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
@@ -37,3 +40,18 @@ func moveButDontOvewrite(path string, targetPath string) {
|
||||
num++
|
||||
}
|
||||
}
|
||||
|
||||
func calculateHash(path string) (string, error) {
|
||||
f, err := os.Open(path)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
h := sha256.New()
|
||||
if _, err := io.Copy(h, f); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return base64.RawStdEncoding.EncodeToString(h.Sum(nil)), nil
|
||||
}
|
||||
Reference in new issue
Block a user