Support relative paths.
This commit is contained in:
parent
f0dd8acdeb
commit
dcc59c5a40
1 changed files with 14 additions and 1 deletions
|
@ -1,12 +1,19 @@
|
||||||
package zenity
|
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) {
|
func selectFile(opts options) (name string, err error) {
|
||||||
var data zenutil.File
|
var data zenutil.File
|
||||||
data.Options.Prompt = opts.title
|
data.Options.Prompt = opts.title
|
||||||
data.Options.Invisibles = opts.showHidden
|
data.Options.Invisibles = opts.showHidden
|
||||||
data.Options.Location, _, err = splitDirAndName(opts.filename)
|
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 {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -35,6 +42,9 @@ func selectFileMultiple(opts options) (list []string, err error) {
|
||||||
data.Options.Prompt = opts.title
|
data.Options.Prompt = opts.title
|
||||||
data.Options.Invisibles = opts.showHidden
|
data.Options.Invisibles = opts.showHidden
|
||||||
data.Options.Location, _, err = splitDirAndName(opts.filename)
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -61,6 +71,9 @@ func selectFileSave(opts options) (name string, err error) {
|
||||||
data.Options.Prompt = opts.title
|
data.Options.Prompt = opts.title
|
||||||
data.Options.Invisibles = opts.showHidden
|
data.Options.Invisibles = opts.showHidden
|
||||||
data.Options.Location, data.Options.Name, err = splitDirAndName(opts.filename)
|
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 {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue