Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Var _FEIP_FileHandle
- Var _FEIP_Line
- Var _FEIP_LineLength
- Var _FEIP_CharNum
- Var _FEIP_Char
- Var _FEIP_Bom
- !macro ForEachINIPair SECTION KEY VALUE
- !ifdef _ForEachINIPair_Open
- !error "There is already a ForEachINIPair clause open!"
- !endif
- !define _ForEachINIPair_Open
- ${If} $_FEIP_FileHandle == ""
- FileOpen $_FEIP_FileHandle $LauncherFile r
- FileReadByte $_FEIP_FileHandle $_FEIP_Bom
- FileReadByte $_FEIP_FileHandle $_FEIP_Line
- IntOp $_FEIP_Line $_FEIP_Line * 256
- Intop $_FEIP_Bom $_FEIP_Line + $_FEIP_Bom
- ${If} $_FEIP_Bom = 0xfeff ;65279
- !ifndef NSIS_UNICODE
- Messagebox MB_ICONEXCLAMATION "$LauncherFile is a utf-16LE file !!!$\nConvert this file to ANSI or re-compile the script with Unicode NSIS !"
- abort
- !endif
- StrCpy $_FEIP_Bom 1
- ${Else}
- StrCpy $_FEIP_Bom 0
- ${EndIf}
- ${EndIf}
- FileSeek $_FEIP_FileHandle 0
- ${Do}
- ClearErrors
- ${if} $_FEIP_Bom = 1
- !ifdef NSIS_UNICODE
- FileReadUTF16LE $_FEIP_FileHandle $_FEIP_Line
- !endif
- ${Else}
- FileRead $_FEIP_FileHandle $_FEIP_Line
- ${EndIf}
- ${TrimNewLines} $_FEIP_Line $_FEIP_Line
- ${If} ${Errors} ; end of file
- ${OrIf} $_FEIP_Line == "[${SECTION}]" ; right section
- ${ExitDo}
- ${EndIf}
- ${Loop}
- ${IfNot} ${Errors} ; right section
- ${Do}
- ${if} $_FEIP_Bom = 1
- !ifdef NSIS_UNICODE
- FileReadUTF16LE $_FEIP_FileHandle $_FEIP_Line
- !endif
- ${Else}
- FileRead $_FEIP_FileHandle $_FEIP_Line
- ${EndIf}
- StrCpy $_FEIP_LineLength $_FEIP_Line 1
- ${If} ${Errors} ; end of file
- ${OrIf} $_FEIP_LineLength == '[' ; new section
- ${ExitDo} ; finished
- ${EndIf}
- ${If} $_FEIP_LineLength == ';' ; a comment line
- ${Continue}
- ${EndIf}
- StrLen $_FEIP_LineLength $_FEIP_Line
- StrCpy $_FEIP_CharNum '0'
- ${Do}
- StrCpy $_FEIP_Char $_FEIP_Line 1 $_FEIP_CharNum
- ${IfThen} $_FEIP_Char == '=' ${|} ${ExitDo} ${|}
- IntOp $_FEIP_CharNum $_FEIP_CharNum + 1
- ${LoopUntil} $_FEIP_CharNum > $_FEIP_LineLength
- ${TrimNewLines} $_FEIP_Line $_FEIP_Line
- ${If} $_FEIP_Char == '='
- StrCpy ${KEY} $_FEIP_Line $_FEIP_CharNum
- IntOp $_FEIP_CharNum $_FEIP_CharNum + 1
- StrCpy ${VALUE} $_FEIP_Line "" $_FEIP_CharNum
- !macroend
- !macro NextINIPair
- !ifndef _ForEachINIPair_Open
- !error "There isn't a ForEachINIPair clause open!"
- !endif
- !undef _ForEachINIPair_Open
- ${EndIf}
- ${Loop}
- ${EndIf}
- ;FileClose $_FEIP_FileHandle
- !macroend
- !define ForEachINIPair '!insertmacro ForEachINIPair'
- !define NextINIPair '!insertmacro NextINIPair'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement