| 1125 | } |
| 1126 | |
| 1127 | int |
| 1128 | XmlFileStream::recvSelf(int commitTag, Channel &theChannel, FEM_ObjectBroker &theBroker) |
| 1129 | { |
| 1130 | static ID idData(3); |
| 1131 | |
| 1132 | sendSelfCount = -1; |
| 1133 | theChannels = new Channel *[1]; |
| 1134 | theChannels[0] = &theChannel; |
| 1135 | |
| 1136 | if (theChannel.recvID(0, commitTag, idData) < 0) { |
| 1137 | opserr << "XmlFileStream::recvSelf() - failed to recv id data\n"; |
| 1138 | return -1; |
| 1139 | } |
| 1140 | |
| 1141 | int fileNameLength = idData(0); |
| 1142 | if (idData(1) == 0) |
| 1143 | theOpenMode = OVERWRITE; |
| 1144 | else |
| 1145 | theOpenMode = APPEND; |
| 1146 | |
| 1147 | if (fileNameLength != 0) { |
| 1148 | if (fileName != 0) |
| 1149 | delete [] fileName; |
| 1150 | fileName = new char[fileNameLength+5]; |
| 1151 | if (fileName == 0) { |
| 1152 | opserr << "XmlFileStream::recvSelf() - out of memory\n"; |
| 1153 | return -1; |
| 1154 | } |
| 1155 | |
| 1156 | Message theMessage(fileName, fileNameLength); |
| 1157 | if (theChannel.recvMsg(0, commitTag, theMessage) < 0) { |
| 1158 | opserr << "XmlFileStream::recvSelf() - failed to recv message\n"; |
| 1159 | return -1; |
| 1160 | } |
| 1161 | |
| 1162 | int tag = idData(2); |
| 1163 | |
| 1164 | sprintf(&fileName[fileNameLength],".%d",tag); |
| 1165 | |
| 1166 | if (this->setFile(fileName, theOpenMode) < 0) { |
| 1167 | opserr << "XmlFileStream::XmlFileStream() - setFile() failed\n"; |
| 1168 | if (fileName != 0) { |
| 1169 | delete [] fileName; |
| 1170 | fileName = 0; |
| 1171 | } |
| 1172 | } |
| 1173 | } |
| 1174 | |
| 1175 | return 0; |
| 1176 | } |
| 1177 | |
| 1178 | void |
| 1179 | XmlFileStream::indent(void) |