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
- !ifdef NSIS_UNICODE
- Var _FEIP_Bom
- !endif
- !macro ForEachINIPair SECTION KEY VALUE
- !ifdef _ForEachINIPair_Open
- !error "There is already a ForEachINIPair clause open!"
- !endif
- !define _ForEachINIPair_Open
- ${If} $_FEIP_FileHandle == ""
- !ifdef NSIS_UNICODE
- FileOpen $_FEIP_FileHandle '$LauncherFile' r
- FileReadWord $_FEIP_FileHandle $_FEIP_Line
- FileClose $_FEIP_FileHandle
- StrCpy $_FEIP_FileHandle ""
- StrCpy $_FEIP_Bom 0
- ${IfThen} $_FEIP_Line = 0xfeff ${|} StrCpy $_FEIP_Bom 1 ${|}
- !endif
- FileOpen $_FEIP_FileHandle $LauncherFile r
- ${Else}
- FileSeek $_FEIP_FileHandle 0
- ${EndIf}
- ${Do}
- ClearErrors
- !ifdef NSIS_UNICODE
- ${if} $_FEIP_Bom = 1
- FileReadUTF16LE $_FEIP_FileHandle $_FEIP_Line
- ${Else}
- !endif
- FileRead $_FEIP_FileHandle $_FEIP_Line
- !ifdef NSIS_UNICODE
- ${EndIf}
- !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}
- !ifdef NSIS_UNICODE
- ${if} $_FEIP_Bom = 1
- FileReadUTF16LE $_FEIP_FileHandle $_FEIP_Line
- ${Else}
- !endif
- FileRead $_FEIP_FileHandle $_FEIP_Line
- !ifdef NSIS_UNICODE
- ${EndIf}
- !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