src/Generic/common/UTF8InputStream.cpp
// The c++ std dictates that open filestreams must be explicitly closed before
// they may open another file. However, the old UTF8InputStream interface would
// close as required on a call to open(), so we must mimic that behavior.

The c++ std dictates that open filestreams must be explicitly closed before
they may open another file. However, the old UTF8InputStream interface would
close as required on a call to open(), so we must mimic that behavior.
The c ++ std dictates that open filestreams must be explicitly closed before they may open another file . However the old UTF8InputStream interface would close as required on a call to open () so we must mimic that behavior .
void UTF8InputStream::open( const char * file ){
	if( this->is_open() )
		this->close();
	std::wifstream::open( file, std::ios::binary );
	if( (!this->is_open()) || (this->fail()) ){
		if (_openFileRetries > 0) {
			unsigned int delay = 1; 
			for (size_t retryNum=0; retryNum<_openFileRetries; retryNum++) {
				std::cerr << "Unable to open \"" << file << "\"; retrying in " << delay << " seconds." << std::endl;
				sleep(delay);
				delay *= 2;
				this->clear();
				std::wifstream::open( file, std::ios::binary );
				if (this->is_open() && (!this->fail()))
					break;
			}
		}
		if( (_openFileRetries==0) || (!this->is_open()) || (this->fail()) ){
			std::stringstream errmsg;
			errmsg << "UTF8InputStream (char) failed to open '" << file << "'";
			throw CannotOpenFileException( "UTF8InputStream::open()", errmsg.str().c_str() );
		}
	}
	registerFileOpen(file);
}
void UTF8InputStream :: open ( const char * file ) { if ( this -> is_open ( ) ) this -> close ( ) ; std :: wifstream :: open ( file , std :: ios :: binary ) ; if ( ( ! this -> is_open ( ) ) || ( this -> fail ( ) ) ) { if ( _openFileRetries > 0 ) { unsigned int delay = 1 ; for ( size_t retryNum = 0 ; retryNum < _openFileRetries ; retryNum ++ ) { std :: cerr << " \" " << file << " \" " << delay << " " << std :: endl ; sleep ( delay ) ; delay *= 2 ; this -> clear ( ) ; std :: wifstream :: open ( file , std :: ios :: binary ) ; if ( this -> is_open ( ) && ( ! this -> fail ( ) ) ) break ; } } if ( ( _openFileRetries == 0 ) || ( ! this -> is_open ( ) ) || ( this -> fail ( ) ) ) { std :: stringstream errmsg ; errmsg << " " << file << " " ; throw CannotOpenFileException ( " " , errmsg . str ( ) . c_str ( ) ) ; } } registerFileOpen ( file ) ; }
The c++ std dictates that open filestreams must be explicitly closed before
they may open another file.
The c ++ std dictates that open filestreams must be explicitly closed before they may open another file .
// one second
