| 1315 | } |
| 1316 | |
| 1317 | BOOL LASreaderTXT::reopen(const char* file_name) |
| 1318 | { |
| 1319 | int i; |
| 1320 | |
| 1321 | if (file_name == 0) |
| 1322 | { |
| 1323 | laserror("file name pointer is zero"); |
| 1324 | return FALSE; |
| 1325 | } |
| 1326 | |
| 1327 | file = fopen_compressed(file_name, "r", &piped); |
| 1328 | if (file == 0) |
| 1329 | { |
| 1330 | laserror("cannot reopen file '%s'", file_name); |
| 1331 | return FALSE; |
| 1332 | } |
| 1333 | |
| 1334 | if (setvbuf(file, NULL, _IOFBF, 10 * LAS_TOOLS_IO_IBUFFER_SIZE) != 0) |
| 1335 | { |
| 1336 | LASMessage(LAS_WARNING, "setvbuf() failed with buffer size %d", 10 * LAS_TOOLS_IO_IBUFFER_SIZE); |
| 1337 | } |
| 1338 | |
| 1339 | // skip lines if we have to |
| 1340 | |
| 1341 | for (i = 0; i < skip_lines; i++) fgets(line, 512, file); |
| 1342 | |
| 1343 | // read the first line with full parse_string |
| 1344 | |
| 1345 | i = 0; |
| 1346 | while (fgets(line, 512, file)) |
| 1347 | { |
| 1348 | if (parse(parse_string)) |
| 1349 | { |
| 1350 | // mark that we found the first point |
| 1351 | i = 1; |
| 1352 | break; |
| 1353 | } |
| 1354 | else |
| 1355 | { |
| 1356 | line[strlen(line) - 1] = '\0'; |
| 1357 | LASMessage(LAS_WARNING, "cannot parse '%s' with '%s'. skipping ...", line, parse_string_unparsed); |
| 1358 | } |
| 1359 | } |
| 1360 | |
| 1361 | // did we manage to parse a line |
| 1362 | |
| 1363 | if (i != 1) |
| 1364 | { |
| 1365 | laserror("could not parse any lines with '%s'", parse_string); |
| 1366 | fclose(file); |
| 1367 | file = 0; |
| 1368 | return FALSE; |
| 1369 | } |
| 1370 | p_idx = 0; |
| 1371 | p_cnt = 0; |
| 1372 | return TRUE; |
| 1373 | } |
| 1374 |
nothing calls this directly
no test coverage detected