MCPcopy Create free account
hub / github.com/chipsalliance/Surelog / readLine

Method readLine

src/Common/FileSystem.cpp:246–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

244}
245
246bool 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
270bool FileSystem::loadContent(PathId fileId, std::vector<char> &content) {
271 if (!fileId) return false;

Callers 6

TESTFunction · 0.80
compileTypespecMethod · 0.80
compileExpressionMethod · 0.80
compileRangesMethod · 0.80
compileStmtMethod · 0.80

Calls

no outgoing calls

Tested by 1

TESTFunction · 0.64