-
Notifications
You must be signed in to change notification settings - Fork 2
/
file.go
67 lines (54 loc) · 1.28 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package desfacer
import (
"github.com/go-git/go-billy/v5"
"github.com/spf13/afero"
)
var _ billy.File = new(File)
// File wraps an afero.File.
type File struct {
path string
a afero.File
}
// NewFile creates a new File.
func NewFile(path string, a afero.File) *File {
return &File{
path: path,
a: a,
}
}
// Name implements billy.File interface.
func (f *File) Name() string {
return f.path
}
// Write implements billy.File interface.
func (f *File) Write(p []byte) (n int, err error) {
return f.a.Write(p)
}
// Read implements billy.File interface.
func (f *File) Read(p []byte) (n int, err error) {
return f.a.Read(p)
}
// ReadAt implements billy.File interface.
func (f *File) ReadAt(p []byte, off int64) (n int, err error) {
return f.a.ReadAt(p, off)
}
// Seek implements billy.File interface.
func (f *File) Seek(offset int64, whence int) (int64, error) {
return f.a.Seek(offset, whence)
}
// Close implements billy.File interface.
func (f *File) Close() error {
return f.a.Close()
}
// Lock implements billy.File interface.
func (f *File) Lock() error {
return nil
}
// Unlock implements billy.File interface.
func (f *File) Unlock() error {
return nil
}
// Truncate implements billy.File interface.
func (f *File) Truncate(size int64) error {
return f.a.Truncate(size)
}