/* choose whether to skip a particular file */ static int skip_file(char *fname, struct file_struct *file, STRUCT_STAT *st) { if (st->st_size != file->length) { return 0; } /* if always checksum is set then we use the checksum instead of the file time to determine whether to sync */ if (always_checksum && S_ISREG(st->st_mode)) { char sum[MD4_SUM_LENGTH]; file_checksum(fname,sum,st->st_size); return (memcmp(sum,file->sum,csum_length) == 0); } if (size_only) { return 1; } if (ignore_times) { return 0; } return (st->st_mtime == file->modtime); }
int irssi_config_is_changed(const char *fname) { struct stat statbuf; if (fname == NULL) fname = mainconfig->fname; if (stat(fname, &statbuf) != 0) return FALSE; return config_last_mtime != statbuf.st_mtime && (config_last_size != statbuf.st_size || config_last_checksum != file_checksum(fname)); }
static void irssi_config_save_state(const char *fname) { struct stat statbuf; g_return_if_fail(fname != NULL); if (stat(fname, &statbuf) != 0) return; /* save modify time, file size and checksum */ config_last_mtime = statbuf.st_mtime; config_last_size = statbuf.st_size; config_last_checksum = file_checksum(fname); }
/* choose whether to skip a particular file */ static int skip_file(char *fname, struct file_struct *file, STRUCT_STAT *st) { if (st->st_size != file->length) { return 0; } /* if always checksum is set then we use the checksum instead of the file time to determine whether to sync */ if (always_checksum && S_ISREG(st->st_mode)) { char sum[MD4_SUM_LENGTH]; char fnamecmpdest[MAXPATHLEN]; if (compare_dest != NULL) { if (access(fname, 0) != 0) { snprintf(fnamecmpdest,MAXPATHLEN,"%s/%s", compare_dest,fname); fname = fnamecmpdest; } } file_checksum(fname,sum,st->st_size); if (remote_version < 21) { return (memcmp(sum,file->sum,2) == 0); } else { return (memcmp(sum,file->sum,MD4_SUM_LENGTH) == 0); } } if (size_only) { return 1; } if (ignore_times) { return 0; } return (cmp_modtime(st->st_mtime,file->modtime) == 0); }