_fseeki64在linux下的头文件,fseek能处理2GB以上的文件吗?

fseek能处理2GB以上的文件吗?

(2012-04-10 03:08:23)

标签:

杂谈

fseek能处理2GB以上的文件吗?fseek函数中偏移量的参数是long int类型的,我机器上long

int是32位的,那么对于超过2GB文件的文件该怎么办呢?找找有没有类似fseeki64之类的函数BTW:

当初制定fseek的人应当受罚,怎么可以硬性定义为long int呢?

应当类似于

typedef long int fpos_t;

int fseek(FILE *stream, fpos_t offset, int whence);

这样当库的实现有能力处理4G以上长度时http://www.boomss.com,只需要修改fpos_t的定义,即fpos_t取决于平台能力。原帖由

ahocat 于 2009-7-7 16:32 发表

http://bbs3.chinaunix.net/images/common/back.gif

fseek函数中偏移量的参数是long int类型的,我机器上long

int是32位的,那么对于超过2GB文件的文件该怎么办呢?

不知道fseek底层是否是用lseek实现的

没有处理过大文件,突然发现自己对于TB级的文件不知道如何处理

翻了一下APUE2

3.6. lseek Function

#include

off_t lseek(int filedes, off_t offset, int whence);

……

Because the offset (off_t) is a signed data type (Figure 2.20), we

lose a factor of 2 in the maximum file size. If off_t is a 32-bit

integer, the maximum file size is 2^31-1 bytes.

……

The Single UNIX Specification provides a way for applications to

determine which environments are supported through the sysconf

function (Section 2.5.4.). Figure 3.3 summarizes the sysconf

constants that are defined.

……

The c99 compiler requires that we use the getconf(1) command to map

the desired data size model to the flags necessary to compile and

link our programs. Different flags and libraries might be needed,

depending on the environments supported by each platform.

Unfortunately, this is one area in which implementations haven't

caught up to the standards. Confusing things further is the name

changes that were made between Version 2 and Version 3 of the

Single UNIX Specification.

To get around this, applications can set the _FILE_OFFSET_BITS

constant to 64 to enable 64-bit offsets. Doing so changes the

definition of off_t to be a 64-bit signed integer. Setting

_FILE_OFFSET_BITS to 32 enables 32-bit file offsets. Be aware,

however, that although all four platforms discus

分享:

a4c26d1e5885305701be709a3d33442f.png喜欢

0

a4c26d1e5885305701be709a3d33442f.png赠金笔

加载中,请稍候......

评论加载中,请稍候...

发评论

登录名: 密码: 找回密码 注册记住登录状态

昵   称:

评论并转载此博文

a4c26d1e5885305701be709a3d33442f.png

发评论

以上网友发言只代表其个人观点,不代表新浪网的观点或立场。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值