file.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Package storage provides storage access and management functionality.
  2. package storage
  3. import (
  4. "errors"
  5. "fyne.io/fyne/v2"
  6. )
  7. // OpenFileFromURI loads a file read stream from a resource identifier.
  8. // This is mostly provided so that file references can be saved using their URI and loaded again later.
  9. //
  10. // Deprecated: this has been replaced by storage.Reader(URI)
  11. func OpenFileFromURI(uri fyne.URI) (fyne.URIReadCloser, error) {
  12. return Reader(uri)
  13. }
  14. // SaveFileToURI loads a file write stream to a resource identifier.
  15. // This is mostly provided so that file references can be saved using their URI and written to again later.
  16. //
  17. // Deprecated: this has been replaced by storage.Writer(URI)
  18. func SaveFileToURI(uri fyne.URI) (fyne.URIWriteCloser, error) {
  19. return Writer(uri)
  20. }
  21. // ListerForURI will attempt to use the application's driver to convert a
  22. // standard URI into a listable URI.
  23. //
  24. // Since: 1.4
  25. func ListerForURI(uri fyne.URI) (fyne.ListableURI, error) {
  26. listable, err := CanList(uri)
  27. if err != nil {
  28. return nil, err
  29. }
  30. if !listable {
  31. return nil, errors.New("uri is not listable")
  32. }
  33. return &legacyListable{uri}, nil
  34. }
  35. type legacyListable struct {
  36. fyne.URI
  37. }
  38. func (l *legacyListable) List() ([]fyne.URI, error) {
  39. return List(l.URI)
  40. }