mirror of https://github.com/dnomd343/XProxy.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
879 B
37 lines
879 B
package assets
|
|
|
|
import (
|
|
"XProxy/logger"
|
|
"io"
|
|
)
|
|
|
|
type asset struct {
|
|
tag string
|
|
stream io.Reader
|
|
archive int
|
|
}
|
|
|
|
func (a *asset) debug(template string, args ...interface{}) {
|
|
logger.Debugf("[%s] "+template, append([]interface{}{a.tag}, args...)...)
|
|
}
|
|
|
|
func (a *asset) error(template string, args ...interface{}) {
|
|
logger.Errorf("[%s] "+template, append([]interface{}{a.tag}, args...)...)
|
|
}
|
|
|
|
func (a *asset) Read(p []byte) (n int, err error) {
|
|
n, err = a.stream.Read(p)
|
|
if err != nil && err != io.EOF { // data stream broken
|
|
switch a.archive {
|
|
case notArchive:
|
|
a.error("Failed to read data stream -> %v", err)
|
|
case gzipArchive:
|
|
a.error("Failed to extract gzip archive -> %v", err)
|
|
case bzip2Archive:
|
|
a.error("Failed to extract bzip2 archive -> %v", err)
|
|
case xzArchive:
|
|
a.error("Failed to extract xz archive -> %v", err)
|
|
}
|
|
}
|
|
return n, err
|
|
}
|
|
|