如何使用 NSIS 读取包含键值对的文本文件?

How to read text file containing key and value pair using NSIS?

我有一个文本文件,其中包含文件名作为键,path/location 作为其值,由单个 space 分隔。文本文件如下-

index1.html /htdocs/abc/htmls/
english.war /tomcat/webapps/
index10.html /htdocs/abc/home/auto/var/

文本文件如上所示。我想使用 nsis 阅读它,我想将 index1.html 或 english.war 等文件保留在该文件名旁边的位置。这里的键是文件名,它的值是它的路径。谁能告诉我如何将此文本文件读取为键值以及如何将其放置在给定路径中?

这些不是 Windows 路径,所以我真的不知道您希望如何将某些内容复制到这些位置,但可以像这样解析文件:

Function StrSplitOne
Exch [=10=] ; Separator
Exch 
Exch  ; String
Push 
Push 
StrCpy  0
loop:
    StrCpy   1 
    IntOp   + 1
    StrCmp  "" +3
    StrCmp  [=10=] 0 loop
    IntOp   - 1
    StrCpy [=10=]  
    IntOp   + 1
    StrCpy   "" 
Pop 
Pop 
Exch  ; Remaining
Exch
Exch [=10=] ; Item
FunctionEnd

Section 
; Create config file for testing
InitPluginsDir
FileOpen [=10=] "$PluginsDir\test.txt" w
FileWrite [=10=] "index1.html /htdocs/abc/htmls/$\r$\n"
FileWrite [=10=] "english.war /tomcat/webapps/$\r$\n"
FileWrite [=10=] "index10.html /htdocs/abc/home/auto/var/$\r$\n"
FileClose [=10=]
SectionEnd

Section
; Read and parse config file
FileOpen [=10=] "$PluginsDir\test.txt" r
loop:
    FileRead [=10=] 
    StrCmp  '' eof
findnewline:
    StrCpy   1 -1
    StrCmp  '$\r' killnewline
    StrCmp  '$\n' killnewline split
killnewline:
    StrCpy   -1
    Goto findnewline
split:
    Push 
    Push ' '
    Call StrSplitOne
    Pop 
    Pop 
    DetailPrint 'Use CopyFiles to copy "?:$2" to "?:"...'
    Goto loop
eof:
FileClose [=10=]
SectionEnd