Skip to content

Commit

Permalink
Remove usages of path where it should not be used
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Oct 10, 2020
1 parent d3d7f45 commit 01b0988
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions dialog/file.go
Expand Up @@ -82,18 +82,18 @@ func (f *fileDialog) makeUI() fyne.CanvasObject {
if f.file.save {
callback := f.file.callback.(func(fyne.URIWriteCloser, error))
name := f.fileName.(*widget.Entry).Text
path, _ := storage.Child(f.dir, name)
location, _ := storage.Child(f.dir, name)

exists, _ := storage.Exists(path)
exists, _ := storage.Exists(location)

_, err := storage.ListerForURI(path)
_, err := storage.ListerForURI(location)

if !exists {
f.win.Hide()
if f.file.onClosedCallback != nil {
f.file.onClosedCallback(true)
}
callback(storage.SaveFileToURI(path))
callback(storage.SaveFileToURI(location))
return
} else if err != nil {
// check if the directory exists
Expand All @@ -109,7 +109,7 @@ func (f *fileDialog) makeUI() fyne.CanvasObject {
}
f.win.Hide()

callback(storage.SaveFileToURI(path))
callback(storage.SaveFileToURI(location))
if f.file.onClosedCallback != nil {
f.file.onClosedCallback(true)
}
Expand All @@ -120,9 +120,7 @@ func (f *fileDialog) makeUI() fyne.CanvasObject {
if f.file.onClosedCallback != nil {
f.file.onClosedCallback(true)
}
path := f.selected.location
// On windows replace '\\' with '/'
callback(storage.OpenFileFromURI(path))
callback(storage.OpenFileFromURI(f.selected.location))
}
})
f.open.Style = widget.PrimaryButton
Expand Down Expand Up @@ -240,7 +238,7 @@ func (f *fileDialog) refreshDir(dir fyne.ListableURI) {

files, err := dir.List()
if err != nil {
fyne.LogError("Unable to read path "+dir.String(), err)
fyne.LogError("Unable to read ListableURI "+dir.String(), err)
return
}

Expand Down

0 comments on commit 01b0988

Please sign in to comment.