| 547 | } |
| 548 | |
| 549 | int |
| 550 | BinaryFileStream::recvSelf(int commitTag, Channel& theChannel, FEM_ObjectBroker& theBroker) |
| 551 | { |
| 552 | static ID idData(3); |
| 553 | |
| 554 | sendSelfCount = -1; |
| 555 | theChannels = new Channel*[1]; |
| 556 | theChannels[0] = &theChannel; |
| 557 | |
| 558 | if (theChannel.recvID(0, commitTag, idData) < 0) { |
| 559 | opserr << "BinaryFileStream::recvSelf() - failed to recv id data\n"; |
| 560 | return -1; |
| 561 | } |
| 562 | |
| 563 | int fileNameLength = idData(0); |
| 564 | if (idData(1) == 0) |
| 565 | theOpenMode = openMode::OVERWRITE; |
| 566 | else |
| 567 | theOpenMode = openMode::APPEND; |
| 568 | |
| 569 | if (fileNameLength != 0) { |
| 570 | if (fileName != 0) |
| 571 | delete[] fileName; |
| 572 | fileName = new char[fileNameLength + 5]; |
| 573 | if (fileName == 0) { |
| 574 | opserr << "BinaryFileStream::recvSelf() - out of memory\n"; |
| 575 | return -1; |
| 576 | } |
| 577 | |
| 578 | Message theMessage(fileName, fileNameLength); |
| 579 | if (theChannel.recvMsg(0, commitTag, theMessage) < 0) { |
| 580 | opserr << "BinaryFileStream::recvSelf() - failed to recv message\n"; |
| 581 | return -1; |
| 582 | } |
| 583 | |
| 584 | int tag = idData(2); |
| 585 | |
| 586 | sprintf(&fileName[fileNameLength], ".%d", tag); |
| 587 | |
| 588 | if (this->setFile(fileName, theOpenMode) < 0) { |
| 589 | opserr << "BinaryFileStream::BinaryFileStream() - setFile() failed\n"; |
| 590 | if (fileName != 0) { |
| 591 | delete[] fileName; |
| 592 | fileName = 0; |
| 593 | } |
| 594 | } |
| 595 | } |
| 596 | |
| 597 | return 0; |
| 598 | } |
| 599 | |
| 600 | |
| 601 | int |