| 361 | } |
| 362 | |
| 363 | int |
| 364 | FileDatastore::recvID(int dataTag, int commitTag, |
| 365 | ID &theID, |
| 366 | ChannelAddress *theAddress) |
| 367 | { |
| 368 | if (currentCommitTag != commitTag) |
| 369 | this->resetFilePointers(); |
| 370 | |
| 371 | currentCommitTag = commitTag; |
| 372 | |
| 373 | FileDatastoreOutputFile *theFileStruct; |
| 374 | |
| 375 | // |
| 376 | // next we see if we already have this file; |
| 377 | // if not we need to create data structure & open it |
| 378 | // if we have data structure, need to check file is opened (we close in a commit) |
| 379 | // |
| 380 | |
| 381 | int idSize = theID.Size(); |
| 382 | int stepSize = (1 + idSize)*sizeof(int); |
| 383 | |
| 384 | theIDFilesIter = theIDFiles.find(idSize); |
| 385 | if (theIDFilesIter == theIDFiles.end()) { |
| 386 | |
| 387 | // we first check if we need to resize recv buffer |
| 388 | if (idSize > currentMaxInt) { |
| 389 | if (this->resizeInt(idSize) < 0) { |
| 390 | opserr << "FileDatastore::recvID() - failed in resizeInt()\n"; |
| 391 | return -1; |
| 392 | } |
| 393 | } |
| 394 | |
| 395 | char *fileName = new char[strlen(dataBase)+21]; |
| 396 | theFileStruct = new FileDatastoreOutputFile; |
| 397 | |
| 398 | if (fileName == 0 || theFileStruct == 0) { |
| 399 | opserr << "FileDatastore::recvID() - out of memory\n"; |
| 400 | return -1; |
| 401 | } |
| 402 | |
| 403 | static char intName[20]; |
| 404 | strcpy(fileName, dataBase); |
| 405 | sprintf(intName,"%d.%d",idSize,commitTag); |
| 406 | strcat(fileName,".IDs."); |
| 407 | strcat(fileName,intName); |
| 408 | |
| 409 | if (this->openFile(fileName, theFileStruct, stepSize) < 0) { |
| 410 | opserr << "FileDatastore::recvID() - could not open file\n"; |
| 411 | delete [] fileName; |
| 412 | return -1; |
| 413 | } else |
| 414 | theIDFiles.insert(MAP_FILES_TYPE(idSize, theFileStruct)); |
| 415 | |
| 416 | delete [] fileName; |
| 417 | } else { |
| 418 | |
| 419 | theFileStruct = theIDFilesIter->second; |
| 420 | |