ftello / fseeko VS fgetpos / fsetpos [英] ftello/fseeko vs fgetpos/fsetpos

查看:285
本文介绍了ftello / fseeko VS fgetpos / fsetpos的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是ftello / fseeko和fgetpos / fsetpos之间的区别?这两个似乎是文件指针获取/设置使用不透明的偏移类型有时让64位偏移功能。

What is the difference between ftello/fseeko and fgetpos/fsetpos? Both seem to be file pointer getting/setting functions that use opaque offset types to sometimes allow 64 bit offsets.

他们是否支持在不同的平台或不同的标准?是一家从事偏移的类型更加灵活的IT使用?

Are they supported on different platforms or by different standards? Is one more flexible in the type of the offset it uses?

和,顺便说一句,我知道 fgetpos / fsetpos和FTELL / fseek的,但这不可以重复。这个问题询问FTELL / fseek的,答案是的的适用于ftello / fseeko。

And, by the way, I am aware of fgetpos/fsetpos and ftell/fseek, but this is not a duplicate. That question asks about ftell/fseek, and the answer is not applicable to ftello/fseeko.

推荐答案

请参见便携定位的有关差异的详细信息。摘录:

See Portable Positioning for detailed information on the difference. An excerpt:

在一些系统,其中文本流真正从二进制流不同,就不可能重新present文本流的文件位置作为从文件的开头字符的计数。例如,在某些系统文件的位置必须设有code都记录在文件中的偏移量,和字符记录中的偏移量。

On some systems where text streams truly differ from binary streams, it is impossible to represent the file position of a text stream as a count of characters from the beginning of the file. For example, the file position on some systems must encode both a record offset within the file, and a character offset within the record.

因此​​,如果你希望你的程序可以移植到这些系统中,必须遵守一定的规则:

As a consequence, if you want your programs to be portable to these systems, you must observe certain rules:


      
  • 从FTELL文本流返回的值具有到目前为止您已经阅读的字符数没有predictable关系。你可以依靠的唯一的事情是,你可以随后使用它作为偏移参数FSEEK或fseeko搬回到同一个文件的位置。

  •   
  • 在调用FSEEK或fseeko上的文本流,无论是偏移必须为零,或从那里必须SEEK_SET和偏移必须是一个较早呼叫FTELL上相同的流的结果。

  •   
  • 文本流的文件位置指示器的价值,同时也有已经推后与尚未被读取或放弃与ungetc字符不确定。见Unreading。

  •   

在一言以蔽之:fgetpos / fsetpos使用更灵活的结构来存储更多的元数据文件的位置状态,实现更大的便携性(理论上)

In a nutshell: fgetpos/fsetpos use a more flexible structure to store additional metadata about the file position state, enabling greater portability (in theory).

这篇关于ftello / fseeko VS fgetpos / fsetpos的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆