DirState: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
m (Adding new author and category links.) |
Instructor (talk | contribs) No edit summary |
||
Line 2: | Line 2: | ||
== Links == | == Links == | ||
; Latest version of headers "nsh.zip": | ; Latest version of headers "nsh.zip": | ||
: http://forums.winamp.com/showthread.php?s=&threadid=203228&goto=lastpost | : http://forums.winamp.com/showthread.php?s=&threadid=203228&goto=lastpost | ||
If a function is used without | If a function is used without header, put the function code in your script before calling it. | ||
== The Function == | == The Function Description== | ||
<highlight-nsis> | |||
<highlight-nsis> | |||
____________________________________________________________________________ | ____________________________________________________________________________ | ||
Line 26: | Line 28: | ||
; $var=1 (full) | ; $var=1 (full) | ||
; $var=-1 (directory not found) | ; $var=-1 (directory not found) | ||
</highlight-nsis> | |||
Example: | <b>Example:</b> | ||
Section | <highlight-nsis>Section | ||
${DirState} "$TEMP" $R0 | ${DirState} "$TEMP" $R0 | ||
; $R0="1" directory is full | ; $R0="1" directory is full | ||
SectionEnd | SectionEnd | ||
</highlight-nsis> | |||
== The Function Code== | |||
<highlight-nsis> | |||
Function DirState | Function DirState | ||
!define DirState `!insertmacro DirStateCall` | !define DirState `!insertmacro DirStateCall` |
Revision as of 15:00, 4 July 2005
Author: Instructor (talk, contrib) |
Links
- Latest version of headers "nsh.zip"
- http://forums.winamp.com/showthread.php?s=&threadid=203228&goto=lastpost
If a function is used without header, put the function code in your script before calling it.
The Function Description
____________________________________________________________________________ DirState ____________________________________________________________________________ Check directory full, empty or not exist. Syntax: ${DirState} "[path]" $var "[path]" ; Directory $var ; Result: ; $var=0 (empty) ; $var=1 (full) ; $var=-1 (directory not found)
Example:
Section ${DirState} "$TEMP" $R0 ; $R0="1" directory is full SectionEnd
The Function Code
Function DirState !define DirState `!insertmacro DirStateCall` !macro DirStateCall _PATH _RESULT Push `${_PATH}` Call DirState Pop ${_RESULT} !macroend Exch $0 Push $1 ClearErrors FindFirst $1 $0 '$0\*.*' IfErrors 0 +3 StrCpy $0 -1 goto end StrCmp $0 '.' 0 +4 FindNext $1 $0 StrCmp $0 '..' 0 +2 FindNext $1 $0 FindClose $1 IfErrors 0 +3 StrCpy $0 0 goto end StrCpy $0 1 end: Pop $1 Exch $0 FunctionEnd