change filepath to script

This commit is contained in:
Niklas 2019-11-04 21:19:05 +01:00
parent d06d136601
commit 8223e02e50

View File

@ -9,6 +9,7 @@ import (
"io/ioutil" "io/ioutil"
"log" "log"
"os" "os"
"path/filepath"
"regexp" "regexp"
"strings" "strings"
@ -62,7 +63,7 @@ func isPGPMessage(msg string) (bool, error) {
return matched, err return matched, err
} }
func isEncrypted(mail *message.Entity) (bool) { func isEncrypted(mail *message.Entity) bool {
t, _, _ := mail.Header.ContentType() t, _, _ := mail.Header.ContentType()
if strings.ToLower(t) == "multipart/encrypted" { if strings.ToLower(t) == "multipart/encrypted" {
return true return true
@ -131,6 +132,18 @@ func encryptEML(eml string, armoredKeyRing *string) {
} }
func main() { func main() {
dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
if err != nil {
log.Fatal(err)
}
if !strings.HasPrefix(dir, os.TempDir()) {
err = os.Chdir(dir)
if err != nil {
log.Fatal(err)
}
}
cfg, err := ini.Load("config.ini") cfg, err := ini.Load("config.ini")
if err != nil { if err != nil {
fmt.Printf("Fail to read file: %v", err) fmt.Printf("Fail to read file: %v", err)