mirror of
https://github.com/glest/glest-source.git
synced 2025-02-24 11:42:31 +01:00
- copyfile copies files in binary mode now
This commit is contained in:
parent
c54a6ca7e5
commit
42d6f16ed1
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
// =====================================
|
// =====================================
|
||||||
|
Loading…
x
Reference in New Issue
Block a user