| 50 | } |
| 51 | |
| 52 | bool ReadProtoFromBinaryFile(const char* filename, Message* proto) { |
| 53 | int fd = open(filename, O_RDONLY); |
| 54 | CHECK_NE(fd, -1) << "File not found: " << filename; |
| 55 | ZeroCopyInputStream* raw_input = new FileInputStream(fd); |
| 56 | CodedInputStream* coded_input = new CodedInputStream(raw_input); |
| 57 | coded_input->SetTotalBytesLimit(kProtoReadBytesLimit, 536870912); |
| 58 | |
| 59 | bool success = proto->ParseFromCodedStream(coded_input); |
| 60 | |
| 61 | delete coded_input; |
| 62 | delete raw_input; |
| 63 | close(fd); |
| 64 | return success; |
| 65 | } |
| 66 | |
| 67 | void WriteProtoToBinaryFile(const Message& proto, const char* filename) { |
| 68 | fstream output(filename, ios::out | ios::trunc | ios::binary); |
no outgoing calls
no test coverage detected