github.com/iikira/iikira-go-utils@v0.0.0-20230610031953-f2cb11cde33a/requester/downloader/writer.go (about) 1 package downloader 2 3 import ( 4 "io" 5 "os" 6 ) 7 8 type ( 9 // Fder 获取fd接口 10 Fder interface { 11 Fd() uintptr 12 } 13 14 // Writer 下载器数据输出接口 15 Writer interface { 16 io.WriterAt 17 } 18 ) 19 20 // NewDownloaderWriterByFilename 创建下载器数据输出接口, 类似于os.OpenFile 21 func NewDownloaderWriterByFilename(name string, flag int, perm os.FileMode) (writer Writer, file *os.File, err error) { 22 file, err = os.OpenFile(name, flag, perm) 23 if err != nil { 24 return 25 } 26 27 writer = file 28 return 29 }