| 662 | } |
| 663 | |
| 664 | void CheckedFile::close() |
| 665 | { |
| 666 | if ( fd_ >= 0 ) |
| 667 | { |
| 668 | #if defined( _MSC_VER ) |
| 669 | int result = ::_close( fd_ ); |
| 670 | #elif defined( __GNUC__ ) |
| 671 | int result = ::close( fd_ ); |
| 672 | #else |
| 673 | #error "no supported compiler defined" |
| 674 | #endif |
| 675 | if ( result < 0 ) |
| 676 | { |
| 677 | throw E57_EXCEPTION2( ErrorCloseFailed, |
| 678 | "fileName=" + fileName_ + " result=" + toString( result ) ); |
| 679 | } |
| 680 | |
| 681 | fd_ = -1; |
| 682 | } |
| 683 | |
| 684 | if ( bufView_ != nullptr ) |
| 685 | { |
| 686 | delete bufView_; |
| 687 | bufView_ = nullptr; |
| 688 | |
| 689 | // WARNING: do NOT delete buffer of bufView_ because |
| 690 | // pointer is handled by user !! |
| 691 | } |
| 692 | } |
| 693 | |
| 694 | void CheckedFile::unlink() |
| 695 | { |