| 244 | } |
| 245 | |
| 246 | bool FileSystem::readLine(PathId fileId, int32_t index, std::string &content) { |
| 247 | if (!fileId) return false; |
| 248 | if (index < 1) return false; // Note: index starts at 1. |
| 249 | |
| 250 | bool result = false; |
| 251 | std::istream &strm = openForRead(fileId); |
| 252 | if (strm.good()) { |
| 253 | std::string line; |
| 254 | while ((index > 0) && strm.good() && std::getline(strm, line)) { |
| 255 | --index; |
| 256 | } |
| 257 | |
| 258 | if ((result = (index == 0))) { |
| 259 | while (!line.empty() && |
| 260 | ((line.back() == '\r') || (line.back() == '\n'))) { |
| 261 | line.pop_back(); |
| 262 | } |
| 263 | content = line; |
| 264 | } |
| 265 | } |
| 266 | close(strm); |
| 267 | return result; |
| 268 | } |
| 269 | |
| 270 | bool FileSystem::loadContent(PathId fileId, std::vector<char> &content) { |
| 271 | if (!fileId) return false; |
no outgoing calls