相关内存映射文件技术的大数据文件的读取
有关内存映射文件技术的大数据文件的读取
由于数据量比较大,不能采用Win 32API提供的WriteFile函数,需通过内存映射的方法,将读取大文件,但是不知道如何将该大文件的内容写入另一个文件,求高手
------解决方案--------------------
把另一个文件也映射上来,然后memcpy
------解决方案--------------------
由于数据量比较大,不能采用Win 32API提供的WriteFile函数,需通过内存映射的方法,将读取大文件,但是不知道如何将该大文件的内容写入另一个文件,求高手
------解决方案--------------------
把另一个文件也映射上来,然后memcpy
------解决方案--------------------
#include <sys\stat.h>
#include <io.h>
#include <fcntl.h>
#include <share.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <string.h>
#define MAX_CLU_BYTES 65536
FILE *fo;
int fh;
__int64 offs,offs1;
__int64 rvi64;
int rv,wrv;
unsigned char buf[MAX_CLU_BYTES];
char ofn[_MAX_PATH];
char offstr[80];
void strcpybutcomma(char *t,char *s) {
char c;
while (1) {
c = *s++;
if (','!=c) *t++ = c;
if (0==c) break;
}
}
void main(int argc,char **argv) {
if (argc<3) {
printf("Copy File Tail.\n");
printf("Usage:\n");
printf(" cft filename.ext offset_begin[-offset_end]\n");
printf("Copy filename.ext offset_begin[-offset_end] to offset_begin[-offset_end]-filename.ext\n");
printf("Note: Byte at offset_end is NOT included.\n");
printf("Example:\n");
printf(" cft abc.rar 12345\n");
printf("Copy abc.rar offset 12345-end to 12345-abc.rar\n");
printf(" cft abc.rar 123-12345\n");
printf("Copy abc.rar offset 123-12345 to 123-12345-abc.rar\n");
printf(" cft abc.rar 0xAB-0xCD\n");
printf("Copy abc.rar offset 0xAB-0xCD to 0xAB-0xCD-abc.rar\n");
return;
}
strcpybutcomma(offstr,argv[2]);
rv=sscanf(offstr,"%I64i-%I64i",&offs,&offs1);
if (rv==0) {
printf("offset %s is not number\n",argv[2]);
return;
}
fh=_sopen(argv[1],_O_BINARY
------解决方案--------------------
_O_RDONLY
------解决方案--------------------
_O_RANDOM,_SH_DENYWR);
if (fh==-1) {
printf("_sopen %s errno=%d\n",argv[1],errno);