-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
file_darwin.go
95 lines (84 loc) · 2.31 KB
/
file_darwin.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package zenity
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
}
if opts.attach != nil {
data.Application = opts.attach
}
if i, ok := opts.windowIcon.(string); ok {
data.WindowIcon = i
}
if opts.directory {
data.Operation = "chooseFolder"
} else {
data.Operation = "chooseFile"
data.Options.Type = opts.fileFilters.types()
}
out, err := zenutil.Run(opts.ctx, "file", data)
return strResult(opts, out, err)
}
func selectFileMultiple(opts options) (list []string, err error) {
var data zenutil.File
data.Separator = zenutil.Separator
data.Options.Multiple = true
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
}
if opts.attach != nil {
data.Application = opts.attach
}
if i, ok := opts.windowIcon.(string); ok {
data.WindowIcon = i
}
if opts.directory {
data.Operation = "chooseFolder"
} else {
data.Operation = "chooseFile"
data.Options.Type = opts.fileFilters.types()
}
out, err := zenutil.Run(opts.ctx, "file", data)
return lstResult(opts, out, err)
}
func selectFileSave(opts options) (name string, err error) {
var data zenutil.File
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
}
if opts.attach != nil {
data.Application = opts.attach
}
if i, ok := opts.windowIcon.(string); ok {
data.WindowIcon = i
}
if opts.directory {
data.Operation = "chooseFolder"
} else {
data.Operation = "chooseFileName"
}
out, err := zenutil.Run(opts.ctx, "file", data)
return strResult(opts, out, err)
}