forked from bmaupin/go-epub
-
Notifications
You must be signed in to change notification settings - Fork 7
/
fs.go
38 lines (32 loc) · 852 Bytes
/
fs.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
package epub
import (
"fmt"
"os"
"github.com/go-shiori/go-epub/internal/storage"
"github.com/go-shiori/go-epub/internal/storage/memory"
"github.com/go-shiori/go-epub/internal/storage/osfs"
)
type FSType int
// filesystem is the current filesytem used as the underlying layer to manage the files.
// See the storage.Use method to change it.
var filesystem storage.Storage = osfs.NewOSFS(os.TempDir())
const (
// This defines the local filesystem
OsFS FSType = iota
// This defines the memory filesystem
MemoryFS
)
// Use s as default storage/ This is typically used in an init function.
// Default to local filesystem
func Use(s FSType) error {
switch s {
case OsFS:
filesystem = osfs.NewOSFS(os.TempDir())
case MemoryFS:
//TODO
filesystem = memory.NewMemory()
default:
return fmt.Errorf("unexpected FSType")
}
return nil
}