- if (nread <= 0) {
- break;
- }
-
- size_t nwritten = fwrite (buffer, 1, nread, fddest);
- VERBOSE (DEBUG, fprintf (stderr, "wrote %d bytes\n", (int)nwritten));
- if (nwritten != nread) {
- msg = strdupcat ("Can't write file '", dest, "'", NULL);
+ if (ferror (fdsrc)) {
+ msg = strdupcat ("Can't read file '", src, "'", NULL);
+ } else {
+ size_t nwritten = fwrite (buffer, 1, nread, fddest);
+ VERBOSE (DEBUG, fprintf (stderr, "wrote %d bytes\n", (int)nwritten));
+ if (nwritten != nread) {
+ msg = strdupcat ("Can't write file '", dest, "'", NULL);
+ }