[C语言] 文件操作,解压SZB格式中的一段函数片段;

    fseek( fd, 8192 , SEEK_SET);                /* 跳转至数据段 */
    //开始解压数据;
    int size,n;
    char image_name[32]="";
    for( i=0; i < imagecount ; i++ ){
        size = images[i].imagesize;             /* 获取镜像的大小 */
        unsigned char buffer[size];             /* 创建缓冲区 */
        strncpy(image_name,images[i].filename,sizeof(image_name));
        if ( size != 0) {
            strncpy(buffer,"",sizeof(buffer));  /* 清空缓冲区内容 */
            if ( ( ft=fopen(images[i].filename,"wb") ) == NULL ){
                printf("解压szb时,打开%s失败!\n",image_name);
            }
            printf("解压文件:%s \n", image_name);
            n = fread(buffer, 1, size, fd );
            fwrite(buffer, 1, n, ft);
            fclose(ft);
        }
    }
    fclose(fd);
}

 

posted @ 2013-03-27 12:12  scue  阅读(284)  评论(0编辑  收藏  举报