github.com/TeaOSLab/EdgeNode@v1.3.8/internal/caches/open_file.go (about) 1 // Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. 2 3 package caches 4 5 import ( 6 "io" 7 "os" 8 ) 9 10 type OpenFile struct { 11 fp *os.File 12 meta []byte 13 header []byte 14 version int64 15 size int64 16 } 17 18 func NewOpenFile(fp *os.File, meta []byte, header []byte, version int64, size int64) *OpenFile { 19 return &OpenFile{ 20 fp: fp, 21 meta: meta, 22 header: header, 23 version: version, 24 size: size, 25 } 26 } 27 28 func (this *OpenFile) SeekStart() error { 29 _, err := this.fp.Seek(0, io.SeekStart) 30 return err 31 } 32 33 func (this *OpenFile) Close() error { 34 this.meta = nil 35 return this.fp.Close() 36 }