| 186 | } |
| 187 | |
| 188 | bool FileSystem::readLines(PathId fileId, std::vector<std::string> &lines) { |
| 189 | if (!fileId) return false; |
| 190 | |
| 191 | bool result = false; |
| 192 | std::istream &strm = openForRead(fileId); |
| 193 | if (strm.good()) { |
| 194 | std::string line; |
| 195 | while (!strm.eof() && std::getline(strm, line)) { |
| 196 | while (!line.empty() && |
| 197 | ((line.back() == '\r') || (line.back() == '\n'))) { |
| 198 | line.pop_back(); |
| 199 | } |
| 200 | lines.emplace_back(line); |
| 201 | } |
| 202 | result = strm.eof(); |
| 203 | } |
| 204 | close(strm); |
| 205 | return result; |
| 206 | } |
| 207 | |
| 208 | bool FileSystem::writeLines(PathId fileId, |
| 209 | const std::vector<std::string> &lines, |
no outgoing calls