Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int copyBinaryFile(char* src, char* dst)
- {
- char buffer[BUFFERSIZE] = { 0 };
- FILE* srcFile = NULL;
- FILE* dstFile = NULL;
- size_t bytes = 0;
- srcFile = fopen(src, "rb");
- if (srcFile == NULL)
- {
- printf("[ERROR] Can't open %s file.", src);
- return 0;
- }
- dstFile = fopen(dst, "wb");
- if (dstFile == NULL)
- {
- fclose(srcFile);
- printf("[ERROR] Can't open %s file", dst);
- return 0;
- }
- while ((bytes = fread(buffer, 1, BUFFERSIZE, srcFile)) != 0) {
- if (fwrite(buffer, 1, bytes, dstFile) != bytes) {
- return 0; // or other action
- }
- }
- fclose(srcFile);
- fclose(dstFile);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement