| 589 | } |
| 590 | |
| 591 | BOOL LASreadPoint::read_chunk_table() |
| 592 | { |
| 593 | // read the 8 bytes that store the location of the chunk table |
| 594 | I64 chunk_table_start_position; |
| 595 | try { instream->get64bitsLE((U8*)&chunk_table_start_position); } catch(...) |
| 596 | { |
| 597 | return FALSE; |
| 598 | } |
| 599 | |
| 600 | // this is where the chunks start |
| 601 | I64 chunks_start = instream->tell(); |
| 602 | |
| 603 | // was compressor interrupted before getting a chance to write the chunk table? |
| 604 | if ((chunk_table_start_position + 8) == chunks_start) |
| 605 | { |
| 606 | // no choice but to fail if adaptive chunking was used |
| 607 | if (chunk_size == U32_MAX) |
| 608 | { |
| 609 | // create error string |
| 610 | if (last_error == 0) last_error = new CHAR[128]; |
| 611 | // report error |
| 612 | snprintf(last_error, 128, "compressor was interrupted before writing adaptive chunk table of LAZ file"); |
| 613 | return FALSE; |
| 614 | } |
| 615 | // otherwise we build the chunk table as we read the file |
| 616 | number_chunks = 256; |
| 617 | chunk_starts = (I64*)malloc_las(sizeof(I64) * (number_chunks + 1)); |
| 618 | if (chunk_starts == 0) |
| 619 | { |
| 620 | return FALSE; |
| 621 | } |
| 622 | chunk_starts[0] = chunks_start; |
| 623 | tabled_chunks = 1; |
| 624 | // create warning string |
| 625 | if (last_warning == 0) last_warning = new CHAR[128]; |
| 626 | // report warning |
| 627 | snprintf(last_warning, 128, "compressor was interrupted before writing chunk table of LAZ file"); |
| 628 | return TRUE; |
| 629 | } |
| 630 | |
| 631 | // maybe the stream is not seekable |
| 632 | if (!instream->isSeekable()) |
| 633 | { |
| 634 | // no choice but to fail if adaptive chunking was used |
| 635 | if (chunk_size == U32_MAX) |
| 636 | { |
| 637 | return FALSE; |
| 638 | } |
| 639 | // then we cannot seek to the chunk table but won't need it anyways |
| 640 | number_chunks = 0; |
| 641 | tabled_chunks = 0; |
| 642 | return TRUE; |
| 643 | } |
| 644 | |
| 645 | if (chunk_table_start_position == -1) |
| 646 | { |
| 647 | // the compressor was writing to a non-seekable stream and wrote the chunk table start at the end |
| 648 | if (!instream->seekEnd(8)) |
nothing calls this directly
no test coverage detected