-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathengine.go
57 lines (45 loc) · 906 Bytes
/
engine.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
package bakemono
import "os"
type Engine struct {
path string
SizeMb uint32
SliceSizeKb uint32
fp *os.File
Volume *Vol
}
func NewEngine(cfg *EngineConfig) *Engine {
return &Engine{
path: cfg.Path,
SizeMb: cfg.SizeMb,
SliceSizeKb: cfg.SliceSizeKb,
}
}
func (e *Engine) Init() error {
//var fileSize uint64
//fileSize = uint64(e.SizeMb) * 1024 * 1024
//blocks := fileSize / BlockSize
//fileUse := blocks * BlockSize
fp, err := os.OpenFile(e.path, os.O_RDWR|os.O_CREATE, 0666)
if err != nil {
return err
}
e.fp = fp
err = e.parseVol()
return nil
}
func (e *Engine) parseVol() error {
e.Volume = &Vol{
Path: e.path,
Fp: e.fp,
}
return nil
}
func (e *Engine) Set(key, value []byte) error {
return nil
}
func (e *Engine) Get(key []byte) ([]byte, error) {
return nil, nil
}
func (e *Engine) Delete(key []byte) error {
return nil
}