| 34 | } |
| 35 | |
| 36 | FluxFileProto loadFl2File(const std::string filename) |
| 37 | { |
| 38 | std::ifstream ifs(filename, std::ios::in | std::ios::binary); |
| 39 | if (!ifs.is_open()) |
| 40 | error("cannot open input file '{}': {}", filename, strerror(errno)); |
| 41 | |
| 42 | char buffer[16]; |
| 43 | ifs.read(buffer, sizeof(buffer)); |
| 44 | if (strncmp(buffer, "SQLite format 3", 16) == 0) |
| 45 | error( |
| 46 | "this flux file is too old; please use the upgrade-flux-file tool " |
| 47 | "to upgrade it"); |
| 48 | |
| 49 | FluxFileProto proto; |
| 50 | ifs.seekg(0); |
| 51 | if (!proto.ParseFromIstream(&ifs)) |
| 52 | error("unable to read input file '{}'", filename); |
| 53 | upgradeFluxFile(proto); |
| 54 | return proto; |
| 55 | } |
| 56 | |
| 57 | void saveFl2File(const std::string filename, FluxFileProto& proto) |
| 58 | { |
no test coverage detected