Files
gopeed/download/file_allocate/pre_file_allocate.go
T
2021-04-10 21:10:16 +08:00

13 lines
249 B
Go

package file_allocate
import "os"
type PreFileAllocator struct {
}
func (p *PreFileAllocator) Allocate(name string, size int64) (file *os.File, err error) {
err = os.Truncate(name, size)
file, err = os.OpenFile(name, os.O_RDWR, 0644)
return
}