我可以寻求使用标准库用C超过2GB的位置? [英] Can I seek a position beyond 2GB in C using the standard library?

查看:109
本文介绍了我可以寻求使用标准库用C超过2GB的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想提出一个计划,在C.读取磁盘映像,我试图让便携式的东西,所以我不想用过多的操作系统的库。我知道有一些非常大的文件很多的磁盘映像,但我不确定如何支持这些文件。

I am making a program that reads disk images in C. I am trying to make something portable, so I do not want to use too many OS-specific libraries. I am aware there are many disk images that are very large files but I am unsure how to support these files.

我已经阅读了关于 fseek的,它似乎使用长整型这是不保证支持价值观超过2 31 -1。 fsetpos 似乎支持与 fpos_t 而是一个绝对位置不能指定一个较大的值。我也有,虽然关于使用几个相对与 fseek的寻找,但我不能确定这是否是便携式的。

I have read up on fseek and it seems to use a long int which is not guaranteed to support values over 231-1. fsetpos seems to support a larger value with fpos_t but an absolute position cannot be specified. I have also though about using several relative seeks with fseek but am unsure if this is portable.

我如何支持可移植性支持用C大文件?

How can I support portably support large files in C?

推荐答案

有没有可移植的方法。

There is no portable way.

在Linux上有 fseeko() ftello(),对(需要一些定义,检查<一HREF =htt​​p://man7.org/linux/man-pages/man3/ftello.3.html> ftello() )。

On Linux there are fseeko() and ftello(), pair (need some defines, check ftello()).

在Windows上,我相信你必须使用 _fseeki64() _ftelli64()

On Windows, I believe you have to use _fseeki64() and _ftelli64()

#IFDEF 是你的朋友。

这篇关于我可以寻求使用标准库用C超过2GB的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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