-+
-+static void write_checksums(const char *dirname)
-+{
-+ char fbuf[MAXPATHLEN];
-+ int count = checksum_flist->count;
-+ int new_entries = count > checksum_flist->high + 1;
-+ int counts_match = count == checksum_matches;
-+ int no_skipped = regular_skipped == 0;
-+ time_t latest_time = 0;
-+ FILE *out_fp;
-+ int i;
-+
-+ clean_flist(checksum_flist, 0);
-+
-+ checksum_flist->count = 0;
-+ checksum_matches = 0;
-+ regular_skipped = 0;
-+
-+ if (dry_run)
-+ return;
-+
-+ if (dirname) {
-+ if (pathjoin(fbuf, sizeof fbuf, dirname, ".rsyncsums") >= sizeof fbuf)
-+ return;
-+ } else
-+ strlcpy(fbuf, ".rsyncsums", sizeof fbuf);
-+
-+ if (checksum_flist->high - checksum_flist->low < 0 && no_skipped) {
-+ unlink(fbuf);
-+ return;
-+ }
-+
-+ if (!new_entries && counts_match)
-+ return;
-+
-+ if (!(out_fp = fopen(fbuf, "w")))
-+ return;
-+
-+ for (i = checksum_flist->low; i <= checksum_flist->high; i++) {
-+ struct file_struct *file = checksum_flist->sorted[i];
-+ const char *cp = F_SUM(file);
-+ const char *end = cp + checksum_len;
-+ time_t ctime;
-+ if (!(file->flags & FLAG_SUM_KEEP))
-+ continue;
-+#if SIZEOF_TIME_T == 4
-+ ctime = OPT_EXTRA(file, LEN64_BUMP(file) + SUM_EXTRA_CNT)->num;
-+#else
-+ memcpy(&ctime, cp - SIZEOF_TIME_T, SIZEOF_TIME_T);
-+#endif
-+ if (protocol_version >= 30) {
-+ fprintf(out_fp, "%s ",
-+ file->basename + strlen(file->basename) + 1);
-+ }
-+ if (file->flags & FLAG_SUM_MISSING) {
-+ do {
-+ fprintf(out_fp, "==");
-+ } while (++cp != end);
-+ } else {
-+ do {
-+ fprintf(out_fp, "%02x", CVAL(cp, 0));
-+ } while (++cp != end);
-+ }
-+ if (protocol_version < 30) {
-+ fprintf(out_fp, " %s",
-+ file->basename + strlen(file->basename) + 1);
-+ }
-+ fprintf(out_fp, " %10.0f %10.0f %10.0f %s\n",
-+ (double)F_LENGTH(file), (double)file->modtime,
-+ (double)ctime, file->basename);
-+ if (file->modtime > ctime)
-+ ctime = file->modtime;
-+ if (ctime > latest_time)
-+ latest_time = ctime;
-+ }
-+
-+ fclose(out_fp);
-+
-+ set_modtime(fbuf, latest_time, latest_time);
-+}