Fix non-stream file copying

This commit is contained in:
Les De Ridder 2017-03-07 02:42:33 +01:00
parent 71fe51ec14
commit 481a87de6d
No known key found for this signature in database
GPG Key ID: 5EC132DFA85DB372
1 changed files with 5 additions and 2 deletions

7
main.c
View File

@ -99,8 +99,11 @@ int fn(const char* fpath, const struct stat* sb, int typeflag)
uint8_t buffer[BUFFER_SIZE];
FILE* from = fopen(fpath, "rb");
FILE* to = fopen(output_entry, "wb");
size_t bytes_read = fread(buffer, 1, BUFFER_SIZE, from);
fwrite(buffer, 1, bytes_read, to);
size_t bytes_read = 0;
while((bytes_read = fread(buffer, 1, BUFFER_SIZE, from)) > 0)
{
fwrite(buffer, 1, bytes_read, to);
}
fclose(to);
fclose(from);
}