From: Michael Vrable Date: Fri, 17 Aug 2007 04:38:25 +0000 (-0700) Subject: Switch to stdio-based I/O for writing descriptor file. X-Git-Url: https://git.vrable.net/?a=commitdiff_plain;h=977ee3e11dfea651ed87d92c001067158b7c2ba8;p=cumulus.git Switch to stdio-based I/O for writing descriptor file. This should be a little bit easier to hook into filtering code (we can open the output file, spawn the filter, and then fdopen the resulting descriptor), which will be used when implementing signing of the descriptor files. --- diff --git a/scandir.cc b/scandir.cc index 2d5a3a8..44aedd2 100644 --- a/scandir.cc +++ b/scandir.cc @@ -767,26 +767,29 @@ int main(int argc, char *argv[]) if (backup_scheme.size() > 0) desc_filename += backup_scheme + "-"; desc_filename = desc_filename + desc_buf + ".lbs"; - std::ofstream descriptor(desc_filename.c_str()); + FILE *descriptor = fopen(desc_filename.c_str(), "w"); - descriptor << "Format: LBS Snapshot v0.2\n"; - descriptor << "Producer: LBS " << lbs_version << "\n"; + fprintf(descriptor, "Format: LBS Snapshot v0.2\n"); + fprintf(descriptor, "Producer: LBS %s\n", lbs_version); strftime(desc_buf, sizeof(desc_buf), "%Y-%m-%d %H:%M:%S %z", &time_buf); - descriptor << "Date: " << desc_buf << "\n"; + fprintf(descriptor, "Date: %s\n", desc_buf); if (backup_scheme.size() > 0) - descriptor << "Scheme: " << backup_scheme << "\n"; - descriptor << "Root: " << backup_root << "\n"; + fprintf(descriptor, "Scheme: %s\n", backup_scheme.c_str()); + fprintf(descriptor, "Root: %s\n", backup_root.c_str()); SHA1Checksum checksum_csum; if (checksum_csum.process_file(checksum_filename.c_str())) { - descriptor << "Checksums: " << checksum_csum.checksum_str() << "\n"; + string csum = checksum_csum.checksum_str(); + fprintf(descriptor, "Checksums: %s\n", csum.c_str()); } - descriptor << "Segments:\n"; + fprintf(descriptor, "Segments:\n"); for (std::set::iterator i = segment_list.begin(); i != segment_list.end(); ++i) { - descriptor << " " << *i << "\n"; + fprintf(descriptor, " %s\n", i->c_str()); } + fclose(descriptor); + return 0; }