| 661 | } |
| 662 | |
| 663 | int |
| 664 | DataFileStream::recvSelf(int commitTag, Channel &theChannel, FEM_ObjectBroker &theBroker) |
| 665 | { |
| 666 | static ID idData(3); |
| 667 | |
| 668 | sendSelfCount = -1; |
| 669 | theChannels = new Channel *[1]; |
| 670 | theChannels[0] = &theChannel; |
| 671 | |
| 672 | if (theChannel.recvID(0, commitTag, idData) < 0) { |
| 673 | opserr << "DataFileStream::recvSelf() - failed to recv id data\n"; |
| 674 | return -1; |
| 675 | } |
| 676 | |
| 677 | int fileNameLength = idData(0); |
| 678 | if (idData(1) == 0) |
| 679 | theOpenMode = OVERWRITE; |
| 680 | else |
| 681 | theOpenMode = APPEND; |
| 682 | |
| 683 | if (fileNameLength != 0) { |
| 684 | if (fileName != 0) |
| 685 | delete [] fileName; |
| 686 | fileName = new char[fileNameLength+10]; |
| 687 | if (fileName == 0) { |
| 688 | opserr << "DataFileStream::recvSelf() - out of memory\n"; |
| 689 | return -1; |
| 690 | } |
| 691 | |
| 692 | Message theMessage(fileName, fileNameLength); |
| 693 | if (theChannel.recvMsg(0, commitTag, theMessage) < 0) { |
| 694 | opserr << "DataFileStream::recvSelf() - failed to recv message\n"; |
| 695 | return -1; |
| 696 | } |
| 697 | |
| 698 | int tag = idData(2); |
| 699 | |
| 700 | sprintf(&fileName[fileNameLength],".%d",tag); |
| 701 | |
| 702 | if (this->setFile(fileName, theOpenMode) < 0) { |
| 703 | opserr << "DataFileStream::DataFileStream() - setFile() failed\n"; |
| 704 | if (fileName != 0) { |
| 705 | delete [] fileName; |
| 706 | fileName = 0; |
| 707 | } |
| 708 | } |
| 709 | } |
| 710 | |
| 711 | return 0; |
| 712 | } |
| 713 | |
| 714 | |
| 715 | void |