104 int_type
overflow( int_type c = traits_type::eof() )
override {
105 int_type ret = traits_type::eof();
106 if ( this->canWrite() ) {
107 if ( ! traits_type::eq_int_type( c, traits_type::eof() ) )
109 *pptr() = traits_type::to_char_type( c );
112 if ( pbase() <= pptr() )
114 if ( this->writeData( pbase(), pptr() - pbase() ) )
117 ret = traits_type::not_eof( c );
153 pos_type
seekoff( off_type off_r, std::ios_base::seekdir way_r, std::ios_base::openmode openMode )
override {
154 pos_type ret = pos_type(off_type(-1));
155 if ( !this->canSeek( way_r) )
158 if ( this->isOpen() ) {
159 if ( openMode == std::ios_base::out ) {
161 if ( !this->canWrite() ||
sync() != 0 )
164 ret = this->seekTo( off_r, way_r, openMode );
166 }
else if ( openMode == std::ios_base::in ) {
167 if ( !this->canRead() )
171 const off_type buffEndOff = this->tell();
173 if ( buffEndOff != off_type(-1) ) {
174 if ( way_r == std::ios_base::end ) {
176 ret = this->seekTo( off_r, way_r, openMode );
179 const off_type bufLen = egptr() - eback();
180 const off_type bufStartFileOff = buffEndOff - bufLen;
181 const off_type currPtrFileOffset = buffEndOff - ( egptr() - gptr() );
182 off_type newFOff = off_r;
185 if ( way_r == std::ios_base::cur ) {
186 newFOff += currPtrFileOffset;
187 way_r = std::ios_base::beg;
191 if ( way_r == std::ios_base::beg ) {
192 if ( bufStartFileOff <= newFOff && newFOff <= buffEndOff ) {
196 eback() + ( newFOff - bufStartFileOff ),
198 ret = pos_type( newFOff );
202 ret = this->seekTo( off_r, way_r, openMode );