ChinaUnix.net
相关文章推荐:

lseek获取上一个文件的长度。

我写了双机传输程序。里面有段代码是这样的 Server: ........ off_t curoff, *datbufp; char datbuf[BUFSIZE * 4 + sizeof(off_t)]; char *iovbufp; ......... iovbufp = &datbuf[sizeof(off_t)]; curoff = lseek(fd, 0L, SEEK_CUR); readn = read(fd, iovbufp, jobsize.ps_end - curoff); *(off_t *)datbuf = curoff; if((writen = send(sockfd, datbuf, rea...

by It'sGifted - C/C++ - 2008-04-06 11:01:14 阅读(1003) 回复(1)

相关讨论

[quote][test:/home/test/src/temp]ls -l myfile -rwx---r-x 1 test users 2147483647 Nov 25 10:30 myfile [test:/home/test/src/temp]du -sh myfile 12K myfile[/quote] 为什么只有12K亚?程序是: [code] if (lseek(fd,(off_t)((unsigned long)(1<<31)-2),SEEK_SET) == -1) { fprintf(stdout, "lseek error: %s\n", strerror(errno)); exit(-1); } if ( write(fd, "a", 1) != 1) ...

by THEBEST - C/C++ - 2005-11-25 11:11:09 阅读(663) 回复(4)

[code] #include #include #include #include #include #define FILE_MODE (O_RDWR|O_CREAT) int main(void) { off_t currpos; int fd; fd = creat("file.hole", FILE_MODE); if(fd == -1){ perror("creat"); return 1; } currpos = lsee...

by xiaozhu2007 - C/C++ - 2007-11-22 11:20:44 阅读(2610) 回复(6)

#include #include #include #include"apue.h" #include"unix_err.h" int main(void) { int wfd; char buf[]="abcd"; if( (wfd = creat("foo", FILE_MODE)) < 0) { perror("Create error for foo.\n"); } if(write(wfd, buf, 4) != 4) { perror("Write error for foo. \n"); } if(lseek(wfd, 10, SEEK_CUR) < 0) { perror("lseek error for foo. \n"); } exit(0); } ...

by fan2290 - C/C++ - 2006-09-15 16:39:45 阅读(1431) 回复(5)

有没有可以读取2g以上文件的方法? 谢谢了

by song6295 - C/C++ - 2006-08-30 11:47:27 阅读(1684) 回复(6)

最近在看APUE,lseek不太明白,请大牛讲讲,谢谢

by 看不见的地平线 - C/C++ - 2008-04-01 09:19:26 阅读(970) 回复(2)

为什么我的lseek老是出错?请高手指点,谢谢! 错误提示:Invalid argument 代码如下: #include #include #define PATHSIZE 1024 #define BUFFSIZE 1024 int main() { int ret; int filedes; ssize_t size; off_t off; char pathname[PATHSIZE]; char buf[BUFFSIZE]; strcpy(pathname, "test.txt"); filedes = open(pathname, O_RDONLY); if(filedes == -1) { printf("open fail!\n"); ...

by wuzhiguo - C/C++ - 2008-07-23 20:31:11 阅读(1204) 回复(5)

offset=0x7fffffff+1; lseek(fd,offset,0); error: Invalid argument. how to fix it?

by hjy7094 - C/C++ - 2003-03-25 17:22:58 阅读(639) 回复(3)

how to set _FILE_OFFSET_BITS=64? need make kernel again?

by hjy7094 - 内核/嵌入技术 - 2003-03-25 08:08:44 阅读(427) 回复(0)

#include #include #include int main(void) { int fd; char buf[20]; int size; off_t location; char * filename = "tt.dat"; if( (fd = open(filename,O_RDWR | O_CREAT | O_TRUNC)) == -1){ perror("open"); return 1; } size = write(fd,"Hello C Programming!\n",20); if(size...

by FinalBSD - C/C++ - 2008-07-27 00:32:21 阅读(2826) 回复(12)

int fd; offset_t offset; fd=open("/dev/dsk/c0t1d0s7",O_RDONLY); offset=0x7fffffff+(offset_t)1; lseek64(fd,offset,0); error messages: lseek error, invalid argument. errno:22 if change /dev/dsk/c0t1d0s7 with a large file name(>;2g), it works. how to fix it?

by SaltOnOurSkin - C/C++ - 2003-03-26 12:54:50 阅读(555) 回复(1)