bdfy
16th February 2005 23:01 UTC
FindFile
My installer ( I 've already created 4-5 topic to complete it :)) used to make similiar operations on several dozens files. I looked through the help and write the following code.
Section ""
SetoutPath "$INSTDIR\Missions\"
File "Files\pbtl.exe"
FindFirst $0 $1 "$INSTDIR\Missions\*.pbo"
loop:
DetailPrint $1
;Operations on file $1
ExecWait '"$INSTDIR\Missions\pbtl.exe" -u $1'
Delete "$INSTDIR\Missions\$1"
;<dirname> is just $1 without extension(pbo)
ExecWait '"$INSTDIR\Missions\pbtl.exe" -p <dirname>'
Delete /r "$INSTDIR\Missions\<dirname>\*.*"
FindNext $0 $1
IfErrors 0 +2
goto end
Goto loop
end:
Delete "$INSTDIR\Missions\pbtl.exe"
SectionEnd
How can I get <dirname> ?
Instructor
17th February 2005 08:34 UTC
Section ""
SetoutPath "$INSTDIR\Missions\"
File "Files\pbtl.exe"
FindFirst $0 $1 "$INSTDIR\Missions\*.pbo"
loop1:
DetailPrint "File: $1"
ExecWait '"$INSTDIR\Missions\pbtl.exe" -u $1'
Delete "$INSTDIR\Missions\$1"
FindNext $0 $1
IfErrors 0 loop1
FindFirst $0 $1 "$INSTDIR\Missions\*.*"
loop2:
StrCmp $1 '.' next
StrCmp $1 '..' next
IfFileExists "$1\*.*" 0 next
DetailPrint "Directory: $1"
ExecWait '"$INSTDIR\Missions\pbtl.exe" -p $1'
Delete /r "$INSTDIR\Missions\$1\*.*"
next:
FindNext $0 $1
IfErrors 0 loop2
Delete "$INSTDIR\Missions\pbtl.exe"
SectionEnd
bdfy
17th February 2005 14:13 UTC
Instructor
That's great! It works, but I don't how :( (i mean second part)
StrCmp $1 '.' next
StrCmp $1 '..' next
What's this?
And I need one little addition to this script:
Directory "$INSTDIR\Missions\Resistance" should be skiped.
Instructor
17th February 2005 17:02 UTC
Russian:
Âðîäå, êîãäà óêàçàíà ìàñêà '*.*', èùóòüñÿ system files, åñëè íå íàõîäÿòüñÿ, òî óñòàíàâëèâàåòñÿ output='.', çàòåì èùóòüñÿ system directories, åñëè íå íàõîäÿòüñÿ, òî óñòàíàâëèâàåòñÿ output='..', çàòåì èùóòüñÿ îñòàëüíûå ôàéëû è äèðåêòîðèè.
...
StrCmp $1 '.' next
StrCmp $1 '..' next
StrCmp $1 'Resistance' next
IfFileExists "$1\*.*" 0 next
...
bdfy
17th February 2005 18:25 UTC
Instructor
Russian:
÷òî-òî òóò ðóññêèõ íåìåðÿíî... :)
ß òàê ïîíÿë, ÷òî áåç ýòèõ äâóõ ñòðî÷åê ÿ íè÷åãî íå íàéäó (ó÷èòûâàÿ ÷òî ñèñòåìíûõ àòðèáóòîâ íà ôàéëàõ íåò)? À â õåëïå ÷òî çà ïðèìåð äëÿ FindFirst ñ "StrCmp $1 "" done" ?
10x but I also find alternative way :)
IfFileExists "$1\*.*" 0 next
DetailPrint "Directory: $1"
IffileExists "$INSTDIR\Missions\Resistance\$1\mission.sqm" 0 +2
Execwait '"$INSTDIR\Missions\Resistance\pbtl.exe" -p $1'
All directories that should be packed contain mission.sqm...
I also need to do similiar search for "$INSTDIR\Missions\Resistance" (it also contains some pbo's)
Is there any elegant way or I should just repeat the code with different path ?
kichik
17th February 2005 18:32 UTC
If you're speaking in another language, at least provide translation for other users.
Instructor
17th February 2005 19:17 UTC
For any complex operations you can use function "Locate"
WordFunc.nsh + TextFunc.nsh + FileFunc.nsh