archive.go 696 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package archive
  2. // is
  3. const (
  4. StateOpen = int32(0)
  5. AttrNo = int32(0)
  6. AttrYes = int32(1)
  7. AttrBitBadgepay = uint(18)
  8. AttrBitUGCPay = uint(22)
  9. AttrBitIsPGC = uint(9)
  10. )
  11. // IsNormal check archive is normal
  12. func (info *Info) IsNormal() bool {
  13. return info.State >= StateOpen
  14. }
  15. // IsPGC is
  16. func (info *Info) IsPGC() bool {
  17. return info.AttrVal(AttrBitIsPGC) == AttrYes
  18. }
  19. // AttrVal get attr val by bit.
  20. func (info *Info) AttrVal(bit uint) int32 {
  21. return (info.Attribute >> bit) & int32(1)
  22. }
  23. // HasCid check cid is in info.Cids
  24. func (info *Info) HasCid(cid int64) (ok bool) {
  25. for _, id := range info.Cids {
  26. if cid == id {
  27. ok = true
  28. break
  29. }
  30. }
  31. return
  32. }