Hello, is there any way to copy any type of binary/text file to a memory buffer, and then use the buffer to make a copy of that file?
Code:
char* readFileToBuffer(const char* fname, const char* opts) {
FILE* fp = fopen(fname, opts);
if ( !fp ) return 0x00;
fseek(fp, 0, SEEK_END);
long fsize = ftell(fp);
printf("readFileToBuffer(): %d\n", fsize);
char *buff = (char*)malloc(sizeof(char)* fsize+1);
fseek(fp, 0, SEEK_SET);
char* begin = buff;
fread((char*)buff, fsize, 1,fp);
fclose(fp);
return buff;
}
This, actually can`t be used to copy to a new file from the return buffer.