【问题标题】:NSIS Find all .txt filesNSIS 查找所有 .txt 文件
【发布时间】:2011-10-24 16:02:25
【问题描述】:

我目前正在检查 $INSTDIR 中的所有文本文件,如下所示。

但是,可能存在子目录,例如 $INSTDIR\mySub,其中包含其他 .txt 文件。有没有办法保持类似的循环结构但同时搜索所有子目录?

FindFirst $R0 $R1 "$INSTDIR\*.txt"
IfErrors ExitInstaller 0
LoopIt:
  Messagebox MB_OK "Do some processing on $R1"
  FindNext $R0 $R1
  IfErrors 0 LoopIt

【问题讨论】:

    标签: search directory find nsis findfirst


    【解决方案1】:
    Function ProcessTextFiles
    Exch $0
    Push $1
    Push $2
    FindFirst $1 $2 "$0\*.txt"
    loop:
        IfErrors end
        DetailPrint 'Found "$0\$2"'
        FindNext $1 $2
        goto loop
    end:
    FindClose $1
    FindFirst $1 $2 "$0\*.*"
    dirloop:
        IfErrors dirend 
        IfFileExists "$0\$2\*.*" 0 dirnext
        StrCmp $2 "." dirnext
        StrCmp $2 ".." dirnext
        Push "$0\$2"
        call ${__FUNCTION__}
    dirnext:
        FindNext $1 $2
        goto dirloop
    dirend:
    FindClose $1
    Pop $2
    Pop $1
    Pop $0
    FunctionEnd
    
    section
    push "$InstDir"
    call ProcessTextFiles
    sectionend
    

    【讨论】:

    【解决方案2】:

    尝试改用Locate 函数——这可能是更好的解决方案。您可以编写选项来查找有(或没有)子目录、定义掩码等。有关文档和示例,请参阅 http://nsis.sourceforge.net/Locate

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-10-23
      • 2012-06-28
      • 2018-01-13
      • 2013-10-27
      • 1970-01-01
      • 1970-01-01
      • 2013-06-20
      相关资源
      最近更新 更多