forked from fyne-io/fyne
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile.go
48 lines (40 loc) · 1.24 KB
/
file.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
// Package storage provides storage access and management functionality.
package storage
import (
"errors"
"fyne.io/fyne/v2"
)
// OpenFileFromURI loads a file read stream from a resource identifier.
// This is mostly provided so that file references can be saved using their URI and loaded again later.
//
// Deprecated: this has been replaced by storage.Reader(URI)
func OpenFileFromURI(uri fyne.URI) (fyne.URIReadCloser, error) {
return Reader(uri)
}
// SaveFileToURI loads a file write stream to a resource identifier.
// This is mostly provided so that file references can be saved using their URI and written to again later.
//
// Deprecated: this has been replaced by storage.Writer(URI)
func SaveFileToURI(uri fyne.URI) (fyne.URIWriteCloser, error) {
return Writer(uri)
}
// ListerForURI will attempt to use the application's driver to convert a
// standard URI into a listable URI.
//
// Since: 1.4
func ListerForURI(uri fyne.URI) (fyne.ListableURI, error) {
listable, err := CanList(uri)
if err != nil {
return nil, err
}
if !listable {
return nil, errors.New("uri is not listable")
}
return &legacyListable{uri}, nil
}
type legacyListable struct {
fyne.URI
}
func (l *legacyListable) List() ([]fyne.URI, error) {
return List(l.URI)
}