我正在写一个文件传输程序。但是出于某种原因pread
正在返回0
,尽管不在文件的末尾。任何人都可以看看我的代码,看看问题?它与fread
完美配合。
int file;
unsigned int size = selfp->intdata;
file=open(str, O_RDONLY);
char buf[1024];
printf("filename = %s \n", str);//prints file name requested
printf("buffer = %s \n", buf);//prints nothing currently
printf("offset = %d \n",atoi(chunkIndex)*CHUNK);//prints 0 for first chunk
printf("CHUNK = %d \n", CHUNK);//prints 1024
int myoffset = atoi(chunkIndex)*CHUNK;
int dataSize=pread(file, buf, sizeof buf, myoffset);
printf("%d\n", dataSize);//returns 0
close(file);
谢谢!