Fixing Windows Path Handling

This commit is contained in:
Sarah Jamie Lewis 2020-03-20 17:00:04 -07:00
parent cbe0e65472
commit c6ab753810
5 changed files with 35 additions and 11 deletions

View File

@ -13,7 +13,7 @@ import (
"golang.org/x/crypto/nacl/box"
"io/ioutil"
"os"
"path"
path "path/filepath"
"strings"
)
@ -104,9 +104,9 @@ func (lapi *LockBoxAPI) generateKey(keyPath string) {
if err == nil {
publicStr := base64.StdEncoding.EncodeToString(public[:])
privateStr := base64.StdEncoding.EncodeToString(private[:])
err = ioutil.WriteFile(path.Join(cleanPath(keyPath), "key.public"), []byte(publicStr), 0644)
err = ioutil.WriteFile(cleanPath(path.Join(cleanPath(keyPath), "key.public")), []byte(publicStr), 0644)
if err == nil {
err = ioutil.WriteFile(path.Join(cleanPath(keyPath), "key.private"), []byte(privateStr), 0644)
err = ioutil.WriteFile(cleanPath(path.Join(cleanPath(keyPath), "key.private")), []byte(privateStr), 0644)
if err == nil {
lapi.Saved(true, "Key File Saved")
return
@ -122,6 +122,11 @@ func (lapi *LockBoxAPI) generateKey(keyPath string) {
lapi.Saved(false, err.Error())
}
func cleanPath(path string) string {
return strings.Replace(path, "file://", "", 1)
func cleanPath(uncleanPath string) string {
cleanPath := path.Join(strings.Replace(uncleanPath, "file://", "", 1))
if len(cleanPath) > 1 && cleanPath[0] == '\\' {
return cleanPath[1:]
}
return cleanPath
}

4
go.mod
View File

@ -5,6 +5,8 @@ go 1.13
require (
cwtch.im/tapir v0.1.17 // indirect
git.openprivacy.ca/openprivacy/log v1.0.0
github.com/therecipe/qt v0.0.0-20191101232336-18864661ae4f
github.com/therecipe/qt v0.0.0-20200126204426-5074eb6d8c41
github.com/therecipe/qt/internal/binding/files/docs/5.12.0 v0.0.0-20200126204426-5074eb6d8c41 // indirect
github.com/therecipe/qt/internal/binding/files/docs/5.13.0 v0.0.0-20200126204426-5074eb6d8c41 // indirect
golang.org/x/crypto v0.0.0-20200206161412-a0c6ece9d31a
)

11
go.sum
View File

@ -27,6 +27,7 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 h1:hLDRPB66XQT/8+wG9WsDpiCvZf1yKO7sz7scAjSlBa0=
github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@ -36,6 +37,15 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/therecipe/qt v0.0.0-20191101232336-18864661ae4f h1:06ICDSmDOBUC9jwgv44ngvyHzwudJNLa5H+rbCyDFRY=
github.com/therecipe/qt v0.0.0-20191101232336-18864661ae4f/go.mod h1:SUUR2j3aE1z6/g76SdD6NwACEpvCxb3fvG82eKbD6us=
github.com/therecipe/qt v0.0.0-20200126204426-5074eb6d8c41 h1:yBVcrpbaQYJBdKT2pxTdlL4hBE/eM4UPcyj9YpyvSok=
github.com/therecipe/qt v0.0.0-20200126204426-5074eb6d8c41/go.mod h1:SUUR2j3aE1z6/g76SdD6NwACEpvCxb3fvG82eKbD6us=
github.com/therecipe/qt/internal/binding/files/docs v0.0.0-20191019224306-1097424d656c h1:/VhcwU7WuFEVgDHZ9V8PIYAyYqQ6KNxFUjBMOf2aFZM=
github.com/therecipe/qt/internal/binding/files/docs/5.12.0 v0.0.0-20200126204426-5074eb6d8c41 h1:My9HYsfDI/fJPZGyilw6066buBiZ7pgKRRgAyvKK5lA=
github.com/therecipe/qt/internal/binding/files/docs/5.12.0 v0.0.0-20200126204426-5074eb6d8c41/go.mod h1:7m8PDYDEtEVqfjoUQc2UrFqhG0CDmoVJjRlQxexndFc=
github.com/therecipe/qt/internal/binding/files/docs/5.13.0 v0.0.0-20191101232336-18864661ae4f h1:NLmalUtBOLr8mUB1/um4PO1KAx66AXlQF/lkrg5vTek=
github.com/therecipe/qt/internal/binding/files/docs/5.13.0 v0.0.0-20191101232336-18864661ae4f/go.mod h1:mH55Ek7AZcdns5KPp99O0bg+78el64YCYWHiQKrOdt4=
github.com/therecipe/qt/internal/binding/files/docs/5.13.0 v0.0.0-20200126204426-5074eb6d8c41 h1:jTzKrQ6EIPvKw1B9/wwoKJLrXF+ManMsXoUzufxAdsg=
github.com/therecipe/qt/internal/binding/files/docs/5.13.0 v0.0.0-20200126204426-5074eb6d8c41/go.mod h1:mH55Ek7AZcdns5KPp99O0bg+78el64YCYWHiQKrOdt4=
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
@ -55,6 +65,7 @@ golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5 h1:LfCXLvNmTYH9kEmVgqbnsWfruoXZIrh4YBgqVHtDvw0=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190420181800-aa740d480789 h1:FF0rjo15h51+N6642mf5S3QuplmKo2aCrJUYkHTx85s=
golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

View File

@ -25,9 +25,9 @@ func main() {
engine.RootContext().SetContextProperty("lockbox", lockapi)
// load the embedded qml file
// created by either qtrcc or qtdeploy
//engine.Load(core.NewQUrl3("qrc:/qml/main.qml", 0))
engine.Load(core.NewQUrl3("qrc:/qml/main.qml", 0))
// you can also load a local file like this instead:
engine.Load(core.QUrl_FromLocalFile("./qml/main.qml"))
//engine.Load(core.QUrl_FromLocalFile("./qml/main.qml"))
// start the main Qt event loop
// and block until app.Exit() is called

View File

@ -6,6 +6,7 @@ import QtQuick.Dialogs 1.3
import QtQuick.Layouts 1.12
ApplicationWindow {
id: root
visible: true
@ -13,6 +14,11 @@ ApplicationWindow {
minimumWidth: 640
minimumHeight: 640
background: Rectangle {
visible: true
color: "#FDF3FC"
}
FileDialog {
id: fileDialog
title: "Please choose a file to decrypt"
@ -100,10 +106,10 @@ ApplicationWindow {
width:parent.width
padding:10
Rectangle {
width: parent.width-20
width: parent.width * 0.9
height: 1
color: "black"
border.color: "black"
color: "#dcb8d5"
border.color: "#dcb8d5"
border.width: 1
}
}