148 {
149 std::fstream file;
150 file.open("./scores.dat", std::ios::in);
151 if (!file.is_open()) {
152 std::cout << "No scores file.\n";
154 return;
155 }
156 std::string input;
157 int count = 0;
158 while (std::getline(file, input)) {
159 if (count >= 10)
160 break;
161 if (input.length() > 0) {
162 auto pos = input.find(":");
163 if (pos != std::string::npos) {
164 std::string left = input.substr(0, pos);
165 std::string right = input.substr(pos + 1);
166 scores.push_back(Score(left, std::strtol(right.c_str(), 0, 10)));
167 count++;
168 }
169 }
170 }
171 file.close();
172 sort();
173 }