Jelajahi Sumber

* Need to actually copy data from 'f' to 'newbin->f' if we aren't writing PACK|CONF

svn: 1757
Bryan Drewery 21 tahun lalu
induk
melakukan
a1548a04fa
1 mengubah file dengan 11 tambahan dan 5 penghapusan
  1. 11 5
      src/binary.c

+ 11 - 5
src/binary.c

@@ -113,21 +113,27 @@ bin_checksum(const char *fname, int todo, MD5_CTX * ctx)
 
 
         /* just write both for now */
         /* just write both for now */
         todo |= WRITE_PACK|WRITE_CONF;
         todo |= WRITE_PACK|WRITE_CONF;
-
         skip_bytes += SIZE_PACK;
         skip_bytes += SIZE_PACK;
         if (todo & WRITE_PACK) {
         if (todo & WRITE_PACK) {
           fwrite(&settings.hash, SIZE_PACK, 1, newbin->f);
           fwrite(&settings.hash, SIZE_PACK, 1, newbin->f);
           sdprintf("writing pack: %d\n", SIZE_PACK);
           sdprintf("writing pack: %d\n", SIZE_PACK);
-        } else 
-          fseek(newbin->f, pos + SIZE_PACK, SEEK_SET);
+        } else {
+          fread(buf, 1, SIZE_PACK, f);
+          fwrite(buf, 1, SIZE_PACK, newbin->f);
+        }
+//          fseek(newbin->f, pos + SIZE_PACK, SEEK_SET);
+
         pos += SIZE_PACK;
         pos += SIZE_PACK;
 
 
         skip_bytes += SIZE_CONF;
         skip_bytes += SIZE_CONF;
         if (todo & WRITE_CONF) {
         if (todo & WRITE_CONF) {
           fwrite(&settings.bots, SIZE_CONF, 1, newbin->f);
           fwrite(&settings.bots, SIZE_CONF, 1, newbin->f);
           sdprintf("writing conf: %d\n", SIZE_CONF);
           sdprintf("writing conf: %d\n", SIZE_CONF);
-        } else
-          fseek(newbin->f, pos + SIZE_CONF, SEEK_SET);
+        } else {
+          fread(buf, 1, SIZE_CONF, f);
+          fwrite(buf, 1, SIZE_CONF, newbin->f);
+        }
+//          fseek(newbin->f, pos + SIZE_CONF, SEEK_SET);
         pos += SIZE_CONF;
         pos += SIZE_CONF;
 
 
         skip_bytes += SIZE_PAD;
         skip_bytes += SIZE_PAD;