From 550fbc9cf875549843aa15e975fce9a527eb9fd0 Mon Sep 17 00:00:00 2001 From: fujimoto kyosuke Date: Thu, 9 Jul 2020 05:32:20 +0900 Subject: [PATCH] Avoid calling os.Create in file open dialog --- internal/driver/glfw/file.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/driver/glfw/file.go b/internal/driver/glfw/file.go index 7009f7439b..855b405e27 100644 --- a/internal/driver/glfw/file.go +++ b/internal/driver/glfw/file.go @@ -36,7 +36,12 @@ func openFile(uri fyne.URI, create bool) (*file, error) { } path := uri.String()[7:] - f, err := os.Create(path) // If it exists this will truncate which is what we wanted - + var f *os.File + var err error + if create { + f, err = os.Create(path) // If it exists this will truncate which is what we wanted + } else { + f, err = os.Open(path) + } return &file{File: f, path: path}, err }