Exemplo n.º 1
0
bool flush_config_file(FILE *f, const char *conf_filename) {
	unsigned int len = strlen(cs_confdir) + strlen(conf_filename) + 8;
	char temp_file[len], destfile[len], bakfile[len];
	snprintf(destfile, len, "%s%s"    , cs_confdir, conf_filename);
	snprintf(temp_file,  len, "%s%s.tmp", cs_confdir, conf_filename);
	snprintf(bakfile,  len, "%s%s.bak", cs_confdir, conf_filename);
	fclose(f);
	return safe_overwrite_with_bak(destfile, temp_file, bakfile, 0);
}
Exemplo n.º 2
0
bool flush_config_file(FILE *f, const char *conf_filename) {
	char dst_file[256], tmp_file[256], bak_file[256];
	get_config_filename(dst_file, sizeof(dst_file), conf_filename);
	memcpy(tmp_file, dst_file, sizeof(tmp_file));
	memcpy(bak_file, dst_file, sizeof(bak_file));
	strncat(tmp_file, ".tmp", sizeof(tmp_file) - strlen(tmp_file) - 1);
	strncat(bak_file, ".bak", sizeof(bak_file) - strlen(bak_file) - 1);
	fclose(f);
	return safe_overwrite_with_bak(dst_file, tmp_file, bak_file, 0);
}