开发者

read from file after calling lseek64 - Linux

开发者 https://www.devze.com 2022-12-29 12:32 出处:网络
I\'m trying to read a large file (> 2.0 GB). The seeking is done by lseek64, then I tried to read using read(fileHandle, buffer, bufferLength)\\开发者_如何学编程 pread64(fileHandle, buffer, bufferLeng

I'm trying to read a large file (> 2.0 GB). The seeking is done by lseek64, then I tried to read using read(fileHandle, buffer, bufferLength)\开发者_如何学编程 pread64(fileHandle, buffer, bufferLength, offset) - but both return with -1.

What could it be?

Thanks in advance!


Do you have

#define _FILE_OFFSET_BITS 64

before you include the syscall headers? Otherwise, show some code.


ssize_t count = read(fileHandle, buffer, bufferLength);
if ( count == -1 )
{
 fprintf(stderr, "can't read file: %m\n");
 exit(1);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号