本文整理匯總了Golang中github.com/richardlehane/siegfried.Siegfried.Buffer方法的典型用法代碼示例。如果您正苦於以下問題:Golang Siegfried.Buffer方法的具體用法?Golang Siegfried.Buffer怎麽用?Golang Siegfried.Buffer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/richardlehane/siegfried.Siegfried
的用法示例。
在下文中一共展示了Siegfried.Buffer方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: identifyRdr
func identifyRdr(w writer, s *siegfried.Siegfried, r io.Reader, sz int64, path, mime, mod string) {
lg.set(path)
c, err := s.Identify(r, path, mime)
lg.err(err)
if c == nil {
w.writeFile(path, sz, mod, nil, err, nil)
lg.reset()
return
}
var b *siegreader.Buffer
var cs []byte
if checksum != nil {
b = s.Buffer()
var i int64
l := checksum.BlockSize()
for ; ; i += int64(l) {
buf, _ := b.Slice(i, l)
if buf == nil {
break
}
checksum.Write(buf)
}
cs = checksum.Sum(nil)
checksum.Reset()
}
a := w.writeFile(path, sz, mod, cs, err, idChan(c))
lg.reset()
if !*archive || a == config.None {
return
}
var d decompressor
if b == nil {
b = s.Buffer()
}
switch a {
case config.Zip:
d, err = newZip(siegreader.ReaderFrom(b), path, sz)
case config.Gzip:
d, err = newGzip(b, path)
case config.Tar:
d, err = newTar(siegreader.ReaderFrom(b), path)
case config.ARC:
d, err = newARC(siegreader.ReaderFrom(b), path)
case config.WARC:
d, err = newWARC(siegreader.ReaderFrom(b), path)
}
if err != nil {
writeError(w, path, sz, mod, fmt.Errorf("failed to decompress, got: %v", err))
return
}
for err = d.next(); err == nil; err = d.next() {
if *droido {
for _, v := range d.dirs() {
w.writeFile(v, -1, "", nil, nil, nil)
}
}
identifyRdr(w, s, d.reader(), d.size(), d.path(), d.mime(), d.mod())
}
}
示例2: identifyRdr
func identifyRdr(w writer, s *siegfried.Siegfried, r io.Reader, path string, sz int64, mod string) {
c, err := s.Identify(path, r)
if c == nil {
w.writeFile(path, sz, mod, nil, fmt.Errorf("failed to identify %s, got: %v", path, err), nil)
return
}
var b siegreader.Buffer
var cs []byte
if checksum != nil {
b = s.Buffer()
checksum.Write(siegreader.Bytes(b)) // ignore error returned here
cs = checksum.Sum(nil)
checksum.Reset()
}
a := w.writeFile(path, sz, mod, cs, err, idChan(c))
if !*archive || a == config.None {
return
}
var d decompressor
if b == nil {
b = s.Buffer()
}
switch a {
case config.Zip:
d, err = newZip(siegreader.ReaderFrom(b), path, sz)
case config.Gzip:
d, err = newGzip(b, path)
case config.Tar:
d, err = newTar(siegreader.ReaderFrom(b), path)
}
if err != nil {
w.writeFile(path, sz, mod, nil, fmt.Errorf("failed to decompress %s, got: %v", path, err), nil)
return
}
for err = d.next(); err == nil; err = d.next() {
if *droido {
for _, v := range d.dirs() {
w.writeFile(v, -1, "", nil, nil, nil)
}
}
identifyRdr(w, s, d.reader(), d.path(), d.size(), d.mod())
}
}