wangzhibo
2023-10-31 86070cd00485c47a2c5c3ffa4a9bae6648dd05c6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
; SetFileAttributesDirectoryNormal v 1.1
; Sets all the files in a given directory (and sub directories) to NORMAL attributes
;
; Usage: ${SetFileAttributesDirectoryNormal} DIRECTORY_TO_SET_NORMAL
;
; Macro and Define added by John T. Haller of PortableApps.com
;
; Uses function Attrib v1.1
; http://nsis.sourceforge.net/Attrib
; By: Hendri Adriaens (HendriAdriaens@hotmail.com)
; Additions by hobbyscripter to enable recursion of sub-directories
; BSD License
 
Function SetFileAttributesDirectoryNormal
    Exch $1 ; Dir
    Push $2
    Push $3
    FindFirst $2 $3 "$1\*.*"
    StrCmp $3 "" exitloop
    
    loop:
        StrCmp $3 "" exitloop
        StrCmp $3 "." next
        StrCmp $3 ".." next
        IfFileExists "$1\$3\*.*" 0 +4
            Push "$1\$3"
            Call SetFileAttributesDirectoryNormal
            Goto next
        ; SetFileAttributes does not accept variables as attribute,
        ; so manually set this to the necessary value.
        SetFileAttributes "$1\$3" NORMAL
        
    next:
        FindNext $2 $3
        Goto loop
        
    exitloop:
        FindClose $2
        Pop $3
        Pop $2
        Pop $1
FunctionEnd
 
!macro SetFileAttributesDirectoryNormal DIRECTORY_TO_SET_NORMAL
  Push `${DIRECTORY_TO_SET_NORMAL}`
  Call SetFileAttributesDirectoryNormal
!macroend
 
!define SetFileAttributesDirectoryNormal '!insertmacro "SetFileAttributesDirectoryNormal"'