取的文件大小
1. int fd = open("data.txt",O_RDONLY);
int len = lseek(fd,0,SEEK_END);
2. struct stat sb;
if ((fstat(fd, &sb)) == -1) {
perror("fstat");
}
sb.st_size
3.
if ((mapped = (char *)mmap(NULL, sb.st_size, PROT_READ |
PROT_WRITE, MAP_PRIVATE, fd, 0)) == (void *)-1) {
perror("mmap");
}
原文地址:http://www.cnblogs.com/anjsxz/p/3732888.html