Get number of subdirs in dir path: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Wikipedia python library)
 
m (Updated author and download links, and changed format of some pages.)
Line 41: Line 41:
-Stu
-Stu


Page author: Afrow UK
Page author: [[User:Afrow UK|Afrow UK]]

Revision as of 12:38, 23 April 2005

Description

This script gets the number of sub dirs in a directory path (string) This is useful in conjunction with the UninstallDirs function.

Usage

Push $INSTDIR #input
 Call SubdirsAmount
Pop $R0 ;number of subdirs in $INSTDIR

The Function

Function SubdirsAmount
Exch $R0 ;input string
Push $R1
Push $R2
Push $R3
Push $R4
 StrCpy $R1 0
 StrLen $R2 $R0
loop:
 IntOp $R1 $R1 + 1
  StrCpy $R3 $R0 1 -$R1
 StrCmp $R1 $R2 exit
 StrCmp $R3 "\" 0 loop
  IntOp $R4 $R4 + 1
Goto loop
exit:
StrCpy $R0 $R4
Pop $R4
Pop $R3
Pop $R2
Pop $R1
Exch $R0 ;output
FunctionEnd

Created for tderouin after this topic on the NSIS Forums.

-Stu

Page author: Afrow UK