Documentation
¶
Index ¶
- Constants
- Variables
- type Fav
- func (f *Fav) AddBoard(bid ptttype.Bid) (idx int, favType *FavType, err error)
- func (f *Fav) AddFolder(title string) (idx int, favType *FavType, err error)
- func (f *Fav) AddLine() (idx int, favType *FavType, err error)
- func (f *Fav) CleanParentAndRoot()
- func (f *Fav) DecreaseFavNum()
- func (f *Fav) DeleteFavNum(favNum int)
- func (f *Fav) DeleteIdx(idx int) (err error)
- func (f *Fav) GetBoard(bid ptttype.Bid) (idx int, favType *FavType, err error)
- func (f *Fav) GetFavItem(theID int, theType pttbbsfav.FavT) (idx int, favType *FavType)
- func (f *Fav) Increase(theType pttbbsfav.FavT, fp interface{})
- func (f *Fav) IncreaseFavNum()
- func (f *Fav) LocateFav(levelIdxList []string) (newFav *Fav, err error)
- func (f *Fav) PreAppend(theType pttbbsfav.FavT, fp interface{}) (favType *FavType, err error)
- func (f *Fav) SetFavTypeFavIdx(startFavIdx int) (newFavIdx int)
- func (f *Fav) WriteFavrec(file io.Writer) (err error)
- type FavBoard
- type FavFolder
- type FavLine
- type FavType
Constants ¶
const ( FAV_MAXDEPTH = 5 MAX_FAV = 1024 MAX_LINE = 64 MAX_FOLDER = 64 NEW_FAV_THRESHOLD = 12 )
const ( FAV = ".fav" FAV4 = ".fav4" FAVNB = ".favnb" )
const (
FAV_VERSION int16 = 3363
)
const SIZE_OF_FAV_BOARD = unsafe.Sizeof(FavBoard{})
const SIZE_OF_FAV_FOLDER = unsafe.Sizeof(FavFolder{})
const SIZE_OF_FAV_LINE = unsafe.Sizeof(FavLine{})
Variables ¶
var ( ErrInvalidFavBoard = errors.New("invalid fav-board") ErrInvalidFavLine = errors.New("invalid fav-line") ErrInvalidFavFolder = errors.New("invalid fav-folder") ErrInvalidFavType = errors.New("invalid fav-type") ErrInvalidFavRecord = errors.New("invalid fav-record") ErrInvalidFav4Record = errors.New("invalid fav4-record") ErrOutdatedFav = errors.New("outdated fav") ErrTooManyFavs = errors.New("too many favs") ErrTooManyLines = errors.New("too many lines") ErrTooManyFolders = errors.New("too many folders") ErrTooMuchDepth = errors.New("too much depth") ErrInvalidLevelIdx = errors.New("invalid level-idx") )
Functions ¶
This section is empty.
Types ¶
type Fav ¶
type Fav struct { FavNum int Depth int Root *Fav Parent *Fav NBoards int16 /* number of the boards */ NLines int8 /* number of the lines */ NFolders int8 /* number of the folders */ LineID pttbbsfav.Lid /* current max line id */ FolderID pttbbsfav.Fid /* current max folder id */ Favh []*FavType }
Fav
It's with it's own serialize method and does not directly copy by struct. We can add MTime in FavRaw. The content of FavFolder
func ReadFavrec ¶
ReadFavrec
We need to: 1. read version because calling ReadFavrec 2. run root.SetFavTypeFavIdx(0)
because ReadFavrec is a recursive-call, and the above 2 happens only in the 1st-call.
func (*Fav) CleanParentAndRoot ¶
func (f *Fav) CleanParentAndRoot()
func (*Fav) DecreaseFavNum ¶
func (f *Fav) DecreaseFavNum()
func (*Fav) DeleteFavNum ¶
func (*Fav) GetFavItem ¶
func (*Fav) IncreaseFavNum ¶
func (f *Fav) IncreaseFavNum()
func (*Fav) LocateFav ¶
LocateFav
Locate the fav based on levelIdxList. Requiring that all the fav / subFav are with Folder type.
There will be 1 levelIdx in levelIdxList if referring to f itself. Ex. if referring to f as root, then levelIdxList is []string{""}
func (*Fav) PreAppend ¶
PreAppend
https://github.com/ptt/pttbbs/blob/master/mbbsd/fav.c#L804 Although it is named PreAppend, actually it appends to DataTail