static void * readString( WResFileID handle, long offset, ReadStrErrInfo *err ) /*****************************************************************************/ { char *retstr; if( RCSEEK( handle, offset, SEEK_SET ) == -1 ) { err->status = RS_READ_ERROR; err->err_code = errno; return( NULL ); } else { retstr = ResReadString( handle, NULL ); if( retstr == NULL ) { if( LastWresStatus() == WRS_READ_INCOMPLETE ) { err->status = RS_READ_INCMPLT; } else { err->status = RS_READ_ERROR; err->err_code = LastWresErr(); } return( NULL ); } else { return( retstr ); } } }
static bool copyResourcesFromRes( const char *full_filename ) /***********************************************************/ { WResFileID fid; WResDir dir; bool dup_discarded; WResDirWindow wind; char *buffer; bool error; buffer = NULL; dir = WResInitDir(); fid = RcIoOpenInput( full_filename, false ); if( fid == WRES_NIL_HANDLE ) { RcError( ERR_CANT_OPEN_FILE, full_filename, strerror( errno ) ); goto HANDLE_ERROR; } error = WResReadDir( fid, dir, &dup_discarded ); if( error ) { switch( LastWresStatus() ) { case WRS_BAD_SIG: RcError( ERR_INVALID_RES, full_filename ); break; case WRS_BAD_VERSION: RcError( ERR_BAD_RES_VER, full_filename ); break; default: RcError( ERR_READING_RES, full_filename, LastWresErrStr() ); break; } goto HANDLE_ERROR; } if( WResGetTargetOS( dir ) != WResGetTargetOS( CurrResFile.dir ) ) { RcError( ERR_RES_OS_MISMATCH, full_filename ); goto HANDLE_ERROR; } buffer = RESALLOC( BUFFER_SIZE ); wind = WResFirstResource( dir ); while( !WResIsEmptyWindow( wind ) ) { copyAResource( fid, &wind, buffer, full_filename ); wind = WResNextResource( wind, dir ); } RESFREE( buffer ); WResFreeDir( dir ); RESCLOSE( fid ); return( false ); HANDLE_ERROR: ErrorHasOccured = true; WResFreeDir( dir ); if( fid != WRES_NIL_HANDLE ) RESCLOSE( fid ); return( true ); }