extern bool RcPass2IoInit( void ) /******************************/ { bool noerror; bool tmpexe_exists; memset( &Pass2Info, 0, sizeof( RcPass2Info ) ); Pass2Info.IoBuffer = RESALLOC( IO_BUFFER_SIZE ); noerror = openExeFileInfoRO( CmdLineParms.InExeFileName, &(Pass2Info.OldFile) ); if( noerror ) { Pass2Info.TmpFile.name = "Temporary file 2 (exe)"; Pass2Info.TmpFile.fp = ResOpenFileTmp( NULL ); if( Pass2Info.TmpFile.fp == NULL ) { RcError( ERR_OPENING_TMP, Pass2Info.TmpFile.name, strerror( errno ) ); noerror = false; } } tmpexe_exists = noerror; if( noerror ) { Pass2Info.TmpFile.Type = Pass2Info.OldFile.Type; Pass2Info.TmpFile.WinHeadOffset = Pass2Info.OldFile.WinHeadOffset; if( Pass2Info.OldFile.Type == EXE_TYPE_PE ) { Pass2Info.TmpFile.u.PEInfo.WinHead = &Pass2Info.TmpFile.u.PEInfo.WinHeadData; *Pass2Info.TmpFile.u.PEInfo.WinHead = *Pass2Info.OldFile.u.PEInfo.WinHead; } if( ( Pass2Info.OldFile.Type == EXE_TYPE_NE_WIN || Pass2Info.OldFile.Type == EXE_TYPE_NE_OS2 ) && CmdLineParms.ExtraResFiles != NULL ) { RcError( ERR_FR_NOT_VALID_FOR_WIN ); noerror = false; } else { noerror = OpenResFileInfo( Pass2Info.OldFile.Type ); } } if( !noerror ) { RESFREE( Pass2Info.IoBuffer ); Pass2Info.IoBuffer = NULL; ClosePass2FilesAndFreeMem(); if( tmpexe_exists ) { ResCloseFile( Pass2Info.TmpFile.fp ); Pass2Info.TmpFile.fp = NULL; } } return( noerror ); } /* RcPass2IoInit */
extern int RcPass2IoInit( void ) /******************************/ { int noerror; int tmpexe_exists; memset( &Pass2Info, '\0', sizeof( RcPass2Info ) ); Pass2Info.IoBuffer = RcMemMalloc( IO_BUFFER_SIZE ); MakeTmpInSameDir( CmdLineParms.OutExeFileName, Pass2Info.TmpFileName, "tmp" ); noerror = openExeFileInfoRO( CmdLineParms.InExeFileName, &(Pass2Info.OldFile) ); if( noerror ) { noerror = openNewExeFileInfo( Pass2Info.TmpFileName, &(Pass2Info.TmpFile) ); } tmpexe_exists = noerror; if( noerror ) { Pass2Info.TmpFile.Type = Pass2Info.OldFile.Type; Pass2Info.TmpFile.WinHeadOffset = Pass2Info.OldFile.WinHeadOffset; if( Pass2Info.OldFile.Type == EXE_TYPE_PE ) { Pass2Info.TmpFile.u.PEInfo.WinHead = &Pass2Info.TmpFile.u.PEInfo.WinHeadData; *Pass2Info.TmpFile.u.PEInfo.WinHead = *Pass2Info.OldFile.u.PEInfo.WinHead; } if( (Pass2Info.OldFile.Type == EXE_TYPE_NE_WIN || Pass2Info.OldFile.Type == EXE_TYPE_NE_OS2) && CmdLineParms.ExtraResFiles != NULL ) { RcError( ERR_FR_NOT_VALID_FOR_WIN ); noerror = FALSE; } else { noerror = OpenResFileInfo( Pass2Info.OldFile.Type ); } } if( !noerror ) { RcMemFree( Pass2Info.IoBuffer ); Pass2Info.IoBuffer = NULL; ClosePass2FilesAndFreeMem(); if( tmpexe_exists ) { remove( Pass2Info.TmpFileName ); UnregisterTmpFile( Pass2Info.TmpFileName ); } } return( noerror ); } /* RcPass2IoInit */