From dcc59c5a4044fbd27a1f68094440fb5c4d4dbeec Mon Sep 17 00:00:00 2001 From: Nuno Cruces Date: Wed, 12 Apr 2023 12:52:10 +0100 Subject: [PATCH] Support relative paths. --- file_darwin.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/file_darwin.go b/file_darwin.go index c23db23..7f406dc 100644 --- a/file_darwin.go +++ b/file_darwin.go @@ -1,12 +1,19 @@ package zenity -import "github.com/ncruces/zenity/internal/zenutil" +import ( + "path/filepath" + + "github.com/ncruces/zenity/internal/zenutil" +) func selectFile(opts options) (name string, err error) { var data zenutil.File data.Options.Prompt = opts.title data.Options.Invisibles = opts.showHidden data.Options.Location, _, err = splitDirAndName(opts.filename) + if data.Options.Location != "" && err == nil { + data.Options.Location, err = filepath.Abs(data.Options.Location) + } if err != nil { return "", err } @@ -35,6 +42,9 @@ func selectFileMultiple(opts options) (list []string, err error) { data.Options.Prompt = opts.title data.Options.Invisibles = opts.showHidden data.Options.Location, _, err = splitDirAndName(opts.filename) + if data.Options.Location != "" && err == nil { + data.Options.Location, err = filepath.Abs(data.Options.Location) + } if err != nil { return nil, err } @@ -61,6 +71,9 @@ func selectFileSave(opts options) (name string, err error) { data.Options.Prompt = opts.title data.Options.Invisibles = opts.showHidden data.Options.Location, data.Options.Name, err = splitDirAndName(opts.filename) + if data.Options.Location != "" && err == nil { + data.Options.Location, err = filepath.Abs(data.Options.Location) + } if err != nil { return "", err }