- copyfile copies files in binary mode now

This commit is contained in:
Mark Vejvoda 2011-05-06 23:34:58 +00:00
parent c54a6ca7e5
commit 42d6f16ed1

View File

@ -1838,21 +1838,19 @@ bool searchAndReplaceTextInFile(string fileName, string findText, string replace
} }
void copyFileTo(string fromFileName, string toFileName) { void copyFileTo(string fromFileName, string toFileName) {
const int MAX_LEN_SINGLE_LINE = 4096; //Open an input and output stream in binary mode
char buffer[MAX_LEN_SINGLE_LINE+2]; ifstream in(fromFileName.c_str(),ios::binary);
char *buff_ptr, *find_ptr; ofstream out(toFileName.c_str(),ios::binary);
FILE *fp1, *fp2;
fp1 = fopen(fromFileName.c_str(),"rb"); if(in.is_open() && out.is_open()) {
fp2 = fopen(toFileName.c_str(),"wb"); while(in.eof() == false) {
out.put(in.get());
while(fgets(buffer,MAX_LEN_SINGLE_LINE + 2,fp1)) { }
buff_ptr = buffer;
fputs(buff_ptr,fp2);
} }
fclose(fp2); //Close both files
fclose(fp1); in.close();
out.close();
} }
// ===================================== // =====================================