如何以编程方式计算 DBF 记录?

huangapple 未分类评论48阅读模式
英文:

How to programatically count DBF records?

问题

我正在尝试验证Visual FoxPro DBF文件头中的记录计数与DBF本身中的物理记录计数是否匹配。这个练习的目的是创建一个“穷人”的实用程序,来解决“不是表格”的问题。

我的代码似乎非常接近,但显然我没有读取正确的“这是最后一条记录”的文件标志。

所以,我的代码首先转到文件中的第一个记录偏移量。然后它计算在从read()函数(Java RandomAccessFile)那里得到-1之前,它可以通过记录长度前进多少次。

看起来检查-1只是返回EOF字符,而不是“这是最后一条记录”的字符,无论那是什么。因此,似乎在我正在读取的最后一个物理DBF记录之后还有额外的字节,这导致我的记录计数出现问题。

所以,我想知道,在查看了DBF文档后仍然一无所获的情况下,我如何知道我已经迭代到文件中的最后一个DBF记录偏移量?

我可以发布我的代码,但我不确定这会有帮助。

提前感谢,

英文:

I am trying to verify that the record count in the Visual FoxPro DBF header matches the physical count of records in the DBF itself. The point of this exercise is to create a "poor-man's" utility to fix one of the "Not a table." problems.

My code seems to be very close, but I'm obviously not reading the correct file sentinel for "this is the last record".

So, what my code does is it goes to the first record offset in the file. Then it counts how many times it can advance by the record length before getting a -1 back from the read() (Java RandomAccessFile).

It seems that checking for -1 is just returning the EOF character, but not the "This is the last record" character, whatever that is. So, there appears to be additional bytes beyond the last physical DBF record I'm reading and that's throwing off my record count.

So, I'm wondering, having come up empty looking at DBF documentation, how do I know when I've iterated to the last DBF record offset in the file?

I can post my code, but I'm not sure it would be helpful.

Thanks in advance,

huangapple
  • 本文由 发表于 2020年4月8日 21:19:43
  • 转载请务必保留本文链接:https://java.coder-hub.com/61101706.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定