179 {
180 std::fstream file;
181 file.open("./scores.dat", std::ios::in);
182 if (!file.is_open()) {
183 std::cout << "No scores file.\n";
185 return;
186 }
187 std::string input;
188 int count = 0;
189 while (std::getline(file, input)) {
190 if (count >= 10)
191 break;
192 if (input.length() > 0) {
193 auto pos = input.find(":");
194 if (pos != std::string::npos) {
195 std::string left = input.substr(0, pos);
196 std::string right = input.substr(pos + 1);
197 scores.push_back(Score(left, std::strtol(right.c_str(), 0, 10)));
198 count++;
199 }
200 }
201 }
202 file.close();
204 }