/
repository.go
71 lines (53 loc) · 1.69 KB
/
repository.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
package mobile
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/storage/repository"
)
// declare conformance with repository types
var _ repository.Repository = (*mobileFileRepo)(nil)
var _ repository.HierarchicalRepository = (*mobileFileRepo)(nil)
var _ repository.ListableRepository = (*mobileFileRepo)(nil)
var _ repository.WritableRepository = (*mobileFileRepo)(nil)
type mobileFileRepo struct {
}
func (m *mobileFileRepo) CanList(u fyne.URI) (bool, error) {
return canListURI(u), nil
}
func (m *mobileFileRepo) CanRead(u fyne.URI) (bool, error) {
return true, nil // TODO check a file can be read
}
func (m *mobileFileRepo) CanWrite(u fyne.URI) (bool, error) {
return true, nil // TODO check a file can be written
}
func (m *mobileFileRepo) Child(u fyne.URI, name string) (fyne.URI, error) {
if u == nil || u.Scheme() != "file" {
return nil, repository.ErrOperationNotSupported
}
return repository.GenericChild(u, name)
}
func (m *mobileFileRepo) CreateListable(u fyne.URI) error {
return createListableURI(u)
}
func (m *mobileFileRepo) Delete(u fyne.URI) error {
return deleteURI(u)
}
func (m *mobileFileRepo) Destroy(string) {
}
func (m *mobileFileRepo) Exists(u fyne.URI) (bool, error) {
return existsURI(u)
}
func (m *mobileFileRepo) List(u fyne.URI) ([]fyne.URI, error) {
return listURI(u)
}
func (m *mobileFileRepo) Parent(u fyne.URI) (fyne.URI, error) {
if u == nil || u.Scheme() != "file" {
return nil, repository.ErrOperationNotSupported
}
return repository.GenericParent(u)
}
func (m *mobileFileRepo) Reader(u fyne.URI) (fyne.URIReadCloser, error) {
return fileReaderForURI(u)
}
func (m *mobileFileRepo) Writer(u fyne.URI) (fyne.URIWriteCloser, error) {
return fileWriterForURI(u)
}