'google::protobuf::io::GzipOutputStream does not write anything if the file handle is closed at the end
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?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
