The following code writes to file as expected
int ofd = open(filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0777);
google::protobuf::io::FileOutputStream outp(ofd);
google::protobuf::io::GzipOutputStream fout(&outp);
MyMessage msg;
ConstructMessage(&msg);
CHECK(google::protobuf::util::SerializeDelimitedToZeroCopyStream(msg, &fout));
fout.Close();
// close(ofd);
However if I uncomment the last line // close(ofd);
, I get empty file. Why is that?
Also if I skip using the Gzip wrapper, the last line causes no problem. Does this look like a bug?