/ VCT Access Method opening routine. */ New method now that this routine is called recursively (last table */ first in reverse order): index blocks are immediately linked to */ join block of next table if it exists or else are discarted. */ /
| 412 | /* join block of next table if it exists or else are discarted. */ |
| 413 | /***********************************************************************/ |
| 414 | bool VCTFAM::OpenTableFile(PGLOBAL g) |
| 415 | { |
| 416 | char opmode[4], filename[_MAX_PATH]; |
| 417 | MODE mode = Tdbp->GetMode(); |
| 418 | PDBUSER dbuserp = PlgGetUser(g); |
| 419 | |
| 420 | /*********************************************************************/ |
| 421 | /* Update block info if necessary. */ |
| 422 | /*********************************************************************/ |
| 423 | if (Block < 0) |
| 424 | if ((Headlen = GetBlockInfo(g)) < 0) |
| 425 | return true; |
| 426 | |
| 427 | /*********************************************************************/ |
| 428 | /* Open according to input/output mode required. */ |
| 429 | /*********************************************************************/ |
| 430 | switch (mode) { |
| 431 | case MODE_READ: |
| 432 | snprintf(opmode, sizeof(opmode), "rb"); |
| 433 | break; |
| 434 | case MODE_DELETE: |
| 435 | if (!Tdbp->GetNext()) { |
| 436 | // Store the number of deleted lines |
| 437 | DelRows = Cardinality(g); |
| 438 | |
| 439 | // This will delete the whole file |
| 440 | snprintf(opmode, sizeof(opmode), "wb"); |
| 441 | break; |
| 442 | } // endif |
| 443 | |
| 444 | // Selective delete, pass thru |
| 445 | /* fall through */ |
| 446 | case MODE_UPDATE: |
| 447 | UseTemp = Tdbp->IsUsingTemp(g); |
| 448 | snprintf(opmode, sizeof(opmode), (UseTemp) ? "rb" : "r+b"); |
| 449 | break; |
| 450 | case MODE_INSERT: |
| 451 | if (MaxBlk) { |
| 452 | if (!Block) |
| 453 | if (MakeEmptyFile(g, To_File)) |
| 454 | return true; |
| 455 | |
| 456 | snprintf(opmode, sizeof(opmode), "r+b"); // Required to update empty blocks |
| 457 | } else if (!Block || Last == Nrec) |
| 458 | snprintf(opmode, sizeof(opmode), "ab"); |
| 459 | else |
| 460 | snprintf(opmode, sizeof(opmode), "r+b"); // Required to update the last block |
| 461 | |
| 462 | break; |
| 463 | default: |
| 464 | snprintf(g->Message, sizeof(g->Message), MSG(BAD_OPEN_MODE), mode); |
| 465 | return true; |
| 466 | } // endswitch Mode |
| 467 | |
| 468 | /*********************************************************************/ |
| 469 | /* Use conventionnal input/output functions. */ |
| 470 | /*********************************************************************/ |
| 471 | PlugSetPath(filename, To_File, Tdbp->GetPath()); |
nothing calls this directly
no test coverage detected