| 598 |
|
|
| 599 |
|
const bool newOutput = (access(pout, F_OK) < 0); |
| 600 |
|
FILE *pdfp[2]; |
| 601 |
< |
if (!newOutput) { // output exists? |
| 601 |
> |
if (newOutput) { // new output file? |
| 602 |
> |
CHECK((tileGrid[0] <= 1) & (tileGrid[1] <= 1), |
| 603 |
> |
USER, "bad tiling specification"); |
| 604 |
> |
} else { |
| 605 |
|
dt = myRPmanager.ReopenOutput(pdfp, pout, zout); |
| 606 |
|
if (dt == RDTnone) |
| 607 |
|
quit(1); |
| 611 |
|
myRPmanager.NewHeader(pout); // get prev. header info |
| 612 |
|
const char * tval = myRPmanager.GetHeadStr("TILED="); |
| 613 |
|
if (tval) sscanf(tval, "%d %d", &tileGrid[0], &tileGrid[1]); |
| 614 |
< |
if (!myRPmanager.GetView()) { |
| 615 |
< |
sprintf(errmsg, "missing view in picture file '%s'", pout); |
| 613 |
< |
error(USER, errmsg); |
| 614 |
< |
} |
| 614 |
> |
CHECK(myRPmanager.GetView()==NULL, |
| 615 |
> |
USER, "missing view in picture file"); |
| 616 |
|
ourview = *myRPmanager.GetView(); |
| 617 |
|
} |
| 618 |
|
int hvdim[2] = {hresolu, vresolu}; // set up tiled frame |
| 654 |
|
if (pmlen&7) pmlen += 8 - (pmlen&7); // 8-byte alignment to be safe |
| 655 |
|
pmlen += sizeof(TileProg)*tileGrid[0]*tileGrid[1]; |
| 656 |
|
// map picture file to memory |
| 657 |
< |
if (ftruncate(fileno(pdfp[0]), pmlen) < 0) |
| 657 |
> |
if (newOutput && ftruncate(fileno(pdfp[0]), pmlen) < 0) |
| 658 |
|
error(SYSTEM, "cannot extend picture buffer"); |
| 659 |
|
uby8 * pixMap = (uby8 *)mmap(NULL, pmlen, PROT_READ|PROT_WRITE, |
| 660 |
|
MAP_SHARED, fileno(pdfp[0]), 0); |
| 667 |
|
const size_t zmlen = zdata_beg + zdpSiz*hresolu*vresolu; |
| 668 |
|
uby8 * zdMap = NULL; |
| 669 |
|
if (RDTdepthT(dt)) { |
| 670 |
< |
if (ftruncate(fileno(pdfp[1]), zmlen) < 0) |
| 670 |
> |
if (newOutput && ftruncate(fileno(pdfp[1]), zmlen) < 0) |
| 671 |
|
error(SYSTEM, "cannot extend depth buffer"); |
| 672 |
|
zdMap = (uby8 *)mmap(NULL, zmlen, PROT_READ|PROT_WRITE, |
| 673 |
|
MAP_SHARED, fileno(pdfp[1]), 0); |