1 Star 0 Fork 0

coorrer/unipdf

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
io.go 1.05 KB
一键复制 编辑 原始数据 按行查看 历史
xushuai 提交于 2025-09-24 14:26 +08:00 . fix
package fdf
import (
"bufio"
"errors"
"io"
"gitee.com/coorrer/unipdf/common"
)
// readAtLeast reads at least n bytes into slice p.
// Returns the number of bytes read (should always be == n), and an error on failure.
func (parser *fdfParser) readAtLeast(p []byte, n int) (int, error) {
remaining := n
start := 0
numRounds := 0
for remaining > 0 {
nRead, err := parser.reader.Read(p[start:])
if err != nil {
common.Log.Debug("ERROR Failed reading (%d;%d) %s", nRead, numRounds, err.Error())
return start, errors.New("failed reading")
}
numRounds++
start += nRead
remaining -= nRead
}
return start, nil
}
// getFileOffset returns the current file offset, accounting for buffered position.
func (parser *fdfParser) getFileOffset() int64 {
offset, _ := parser.rs.Seek(0, io.SeekCurrent)
offset -= int64(parser.reader.Buffered())
return offset
}
// setFileOffset seeks the file to an offset position.
func (parser *fdfParser) setFileOffset(offset int64) {
parser.rs.Seek(offset, io.SeekStart)
parser.reader = bufio.NewReader(parser.rs)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/coorrer/unipdf.git
git@gitee.com:coorrer/unipdf.git
coorrer
unipdf
unipdf
v1.3.0

搜索帮助