我应该在 TFileStream.Create 之后调用 Source.Seek(0,soFromBeginning) 吗?
我在很多地方都见过(这里有一个例子: http://pascalgamedevelopment.com /archive/index.php/t-1204.html)人们这样做。
Embarcadero 文档没有提及创建流后文件/流中标头的位置。
结论:
由于文档不保证光标的位置,因此我们应该使用“Seek=0”。即使现在光标位于文件的开头,我们也永远不知道它会如何及时改变。由于 Embarcadero 没有记录这一点,看起来他们保留更改它的权利。
I have seen in quite few places (one example here: http://pascalgamedevelopment.com/archive/index.php/t-1204.html) people doing this.
Embarcadero documentation says nothing about the position of the header in the file/stream after creating the stream.
Conclusion:
Since the documentation does not guaranty the position of the cursor, we should use 'Seek=0'. Even if now the cursor is placed at the beginning of the file, we will never know how this will change in time. Since Embarcadero does not document this, it looks like they reserve the right to change it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
TFileStream.Create 只是打开文件句柄,并将文件位置保留在句柄打开后 Win32 放置的位置 - 在文件的开头。
不需要Seek到0位置;你已经在那里了。
TFileStream.Create just opens file handle and leaves file position where the Win32 put it after the handle was open - at the beginning on the file.
There's no need to Seek to 0 position; you are already there.