add Tell to return the file's current position, like stdio's ftell().

This commit is contained in:
QLeelulu 2013-08-23 18:04:21 +08:00
parent 277b98d6a1
commit 40bd571489
1 changed files with 10 additions and 0 deletions

10
tail.go
View File

@ -91,6 +91,16 @@ func TailFile(filename string, config Config) (*Tail, error) {
return t, nil
}
// Return the file's current position, like stdio's ftell().
// But this value is not very accurate.
func (tail *Tail) Tell() (offser int64, err error) {
offset, err = tail.file.Seek(0, os.SEEK_CUR)
if err == nil {
offset -= int64(tail.reader.Buffered())
}
return
}
// Stop stops the tailing activity.
func (tail *Tail) Stop() error {
tail.Kill(nil)