MCPcopy Create free account
hub / github.com/apache/singa / Count

Method Count

src/io/binfile_reader.cc:64–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62}
63
64int BinFileReader::Count() {
65 std::ifstream fin(path_, std::ios::in | std::ios::binary);
66 CHECK(fin.is_open()) << "Cannot create file " << path_;
67 int count = 0;
68 while (true) {
69 size_t len;
70 char magic[4];
71 fin.read(reinterpret_cast<char*>(magic), sizeof(magic));
72 if (!fin.good()) break;
73 if (magic[2] == 1) {
74 fin.read(reinterpret_cast<char*>(&len), sizeof(len));
75 if (!fin.good()) break;
76 fin.seekg(len, std::ios_base::cur);
77 if (!fin.good()) break;
78 }
79 fin.read(reinterpret_cast<char*>(&len), sizeof(len));
80 if (!fin.good()) break;
81 fin.seekg(len, std::ios_base::cur);
82 if (!fin.good()) break;
83 count++;
84 }
85 fin.close();
86 return count;
87}
88
89void BinFileReader::SeekToFirst() {
90 bufsize_ = 0;

Callers

nothing calls this directly

Calls 2

readMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected