| 540 | |
| 541 | |
| 542 | static void |
| 543 | icvClose( CvFileStorage* fs, std::string* out ) |
| 544 | { |
| 545 | if( out ) |
| 546 | out->clear(); |
| 547 | |
| 548 | if( !fs ) |
| 549 | CV_Error( CV_StsNullPtr, "NULL double pointer to file storage" ); |
| 550 | |
| 551 | if( fs->is_opened ) |
| 552 | { |
| 553 | if( fs->write_mode && (fs->file || fs->gzfile || fs->outbuf) ) |
| 554 | { |
| 555 | if( fs->write_stack ) |
| 556 | { |
| 557 | while( fs->write_stack->total > 0 ) |
| 558 | cvEndWriteStruct(fs); |
| 559 | } |
| 560 | icvFSFlush(fs); |
| 561 | if( fs->fmt == CV_STORAGE_FORMAT_XML ) |
| 562 | icvPuts( fs, "</opencv_storage>\n" ); |
| 563 | } |
| 564 | |
| 565 | icvCloseFile(fs); |
| 566 | } |
| 567 | |
| 568 | if( fs->outbuf && out ) |
| 569 | { |
| 570 | out->resize(fs->outbuf->size()); |
| 571 | std::copy(fs->outbuf->begin(), fs->outbuf->end(), out->begin()); |
| 572 | } |
| 573 | } |
| 574 | |
| 575 | |
| 576 | /* closes file storage and deallocates buffers */ |
no test coverage detected