MakeRecurentFileList: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
(Created page with "{{PageAuthor|Zanir}} == Description == Create file list with relative paths of files in a directory. There is possible to define output file, filter, local and global folder....") |
m (→Description: grammar) |
||
Line 2: | Line 2: | ||
== Description == | == Description == | ||
Create file list with relative paths of files in a directory. | Create file list with relative paths of files in a directory. It is possible to define output file, filter, local and global folder. Local folder and rest path with filename are saved to output file. Global folder is not saved. | ||
== Usage == | == Usage == | ||
<highlight-nsis> | <highlight-nsis> |
Latest revision as of 17:35, 1 September 2015
Author: Zanir (talk, contrib) |
Description
Create file list with relative paths of files in a directory. It is possible to define output file, filter, local and global folder. Local folder and rest path with filename are saved to output file. Global folder is not saved.
Usage
!define UNINSTALL_MAP "uninstall.txt" Delete "$INSTDIR\${UNINSTALL_MAP}" ; delete output file if exist, there is used append mode Push "$INSTDIR\${UNINSTALL_MAP}" ; output file Push ".pdf" ; filter (only files which has this string in filename are added) Push "Doc" ; local folder Push "$EXEDIR" ; global folder Call MakeRecurrentFileList
The Function
!include "StrContains.nsh" ; http://nsis.sourceforge.net/StrContains Function MakeRecurrentFileList Pop $R3 ; global folder Pop $R2 ; local folder Pop $R1 ; filter Pop $R0 ; output file ClearErrors FindFirst $R4 $R5 "$R3\$R2\*.*" MakeRecurrentFileList_Loop: IfErrors MakeRecurrentFileList_Done ; check if it is folder IfFileExists "$R3\$R2\$R5\*.*" 0 MakeRecurrentFileList_file ; directory StrCmp $R5 "." MakeRecurrentFileList_next ; skip current folder StrCmp $R5 ".." MakeRecurrentFileList_next ; skip parent folder ; go Recurrent ; save current variables Push $R5 Push $R4 Push $R3 Push $R2 Push $R1 Push $R0 ; set parameters Push $R0 ; output file Push $R1 ; filter Push "$R2\$R5" ; local folder Push $R3 ; global folder call MakeRecurrentFileList ; restore current variables Pop $R0 Pop $R1 Pop $R2 Pop $R3 Pop $R4 Pop $R5 Goto MakeRecurrentFileList_next MakeRecurrentFileList_file: ; use filter ${StrContains} $0 $R1 $R5 StrCmp $0 "" MakeRecurrentFileList_notfound ; filter found, add file to list FileOpen $R6 $R0 a FileSeek $R6 0 END FileWrite $R6 "$R2\$R5$\r$\n" FileClose $R6 MakeRecurrentFileList_notfound: MakeRecurrentFileList_next: ClearErrors FindNext $R4 $R5 Goto MakeRecurrentFileList_Loop MakeRecurrentFileList_Done: FindClose $R4 FunctionEnd