Skip to content

Commit

Permalink
Version 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
niclaslindstedt committed Oct 13, 2013
0 parents commit 5140435
Show file tree
Hide file tree
Showing 25 changed files with 2,859 additions and 0 deletions.
51 changes: 51 additions & 0 deletions Include/Locate.nsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
!define locate::Open `!insertmacro locate::Open`

!macro locate::Open _PATH _OPTIONS _ERR
locate::_Open /NOUNLOAD `${_PATH}` `${_OPTIONS}`
Pop ${_ERR}
!macroend


!define locate::Find `!insertmacro locate::Find`

!macro locate::Find _PATH_NAME _PATH _NAME _SIZE _TIME _ATTRIB
locate::_Find /NOUNLOAD
Pop ${_PATH_NAME}
Pop ${_PATH}
Pop ${_NAME}
Pop ${_SIZE}
Pop ${_TIME}
Pop ${_ATTRIB}
!macroend


!define locate::Close `!insertmacro locate::Close`

!macro locate::Close
locate::_Close /NOUNLOAD
!macroend


!define locate::GetSize `!insertmacro locate::GetSize`

!macro locate::GetSize _PATH _OPTIONS _SIZE _FILES _DIRS
locate::_GetSize /NOUNLOAD `${_PATH}` `${_OPTIONS}`
Pop ${_SIZE}
Pop ${_FILES}
Pop ${_DIRS}
!macroend


!define locate::RMDirEmpty `!insertmacro locate::RMDirEmpty`

!macro locate::RMDirEmpty _PATH _OPTIONS _REMOVED
locate::_RMDirEmpty /NOUNLOAD `${_PATH}` `${_OPTIONS}`
Pop ${_REMOVED}
!macroend


!define locate::Unload `!insertmacro locate::Unload`

!macro locate::Unload
locate::_Unload
!macroend
62 changes: 62 additions & 0 deletions Include/StrStr.nsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
!define StrStr "!insertmacro StrStr"

!macro StrStr ResultVar String SubString
Push `${String}`
Push `${SubString}`
Call StrStr
Pop `${ResultVar}`
!macroend

Function StrStr
/*After this point:
------------------------------------------
$R0 = SubString (input)
$R1 = String (input)
$R2 = SubStringLen (temp)
$R3 = StrLen (temp)
$R4 = StartCharPos (temp)
$R5 = TempStr (temp)*/

;Get input from user
Exch $R0
Exch
Exch $R1
Push $R2
Push $R3
Push $R4
Push $R5

;Get "String" and "SubString" length
StrLen $R2 $R0
StrLen $R3 $R1
;Start "StartCharPos" counter
StrCpy $R4 0

;Loop until "SubString" is found or "String" reaches its end
${Do}
;Remove everything before and after the searched part ("TempStr")
StrCpy $R5 $R1 $R2 $R4

;Compare "TempStr" with "SubString"
${IfThen} $R5 == $R0 ${|} ${ExitDo} ${|}
;If not "SubString", this could be "String"'s end
${IfThen} $R4 >= $R3 ${|} ${ExitDo} ${|}
;If not, continue the loop
IntOp $R4 $R4 + 1
${Loop}

/*After this point:
------------------------------------------
$R0 = ResultVar (output)*/

;Remove part before "SubString" on "String" (if there has one)
StrCpy $R0 $R1 `` $R4

;Return output to user
Pop $R5
Pop $R4
Pop $R3
Pop $R2
Pop $R1
Exch $R0
FunctionEnd
94 changes: 94 additions & 0 deletions Include/Time.nsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
!define time::GetLocalTime `!insertmacro time::GetLocalTime`

!macro time::GetLocalTime _TIME
time::_GetLocalTime /NOUNLOAD
Pop ${_TIME}
!macroend


!define time::GetLocalTimeUTC `!insertmacro time::GetLocalTimeUTC`

!macro time::GetLocalTimeUTC _TIME
time::_GetLocalTimeUTC /NOUNLOAD
Pop ${_TIME}
!macroend


!define time::SetLocalTime `!insertmacro time::SetLocalTime`

!macro time::SetLocalTime _TIME _ERR
time::_SetLocalTime /NOUNLOAD `${_TIME}`
Pop ${_ERR}
!macroend


!define time::SetLocalTimeUTC `!insertmacro time::SetLocalTimeUTC`

!macro time::SetLocalTimeUTC _TIME _ERR
time::_SetLocalTimeUTC /NOUNLOAD `${_TIME}`
Pop ${_ERR}
!macroend


!define time::GetFileTime `!insertmacro time::GetFileTime`

!macro time::GetFileTime _FILE _CREATION _WRITE _ACCESS
time::_GetFileTime /NOUNLOAD `${_FILE}`
Pop ${_CREATION}
Pop ${_WRITE}
Pop ${_ACCESS}
!macroend


!define time::GetFileTimeUTC `!insertmacro time::GetFileTimeUTC`

!macro time::GetFileTimeUTC _FILE _CREATION _WRITE _ACCESS
time::_GetFileTimeUTC /NOUNLOAD `${_FILE}`
Pop ${_CREATION}
Pop ${_WRITE}
Pop ${_ACCESS}
!macroend


!define time::SetFileTime `!insertmacro time::SetFileTime`

!macro time::SetFileTime _FILE _CREATION _WRITE _ACCESS _ERR
time::_SetFileTime /NOUNLOAD `${_FILE}` `${_CREATION}` `${_WRITE}` `${_ACCESS}`
Pop ${_ERR}
!macroend


!define time::SetFileTimeUTC `!insertmacro time::SetFileTimeUTC`

!macro time::SetFileTimeUTC _FILE _CREATION _WRITE _ACCESS _ERR
time::_SetFileTimeUTC /NOUNLOAD `${_FILE}` `${_CREATION}` `${_WRITE}` `${_ACCESS}`
Pop ${_ERR}
!macroend


!define time::TimeString `!insertmacro time::TimeString`

!macro time::TimeString _TIME _DAY _MONTH _YEAR _HOUR _MINUTE _SECOND
time::_TimeString /NOUNLOAD `${_TIME}`
Pop ${_DAY}
Pop ${_MONTH}
Pop ${_YEAR}
Pop ${_HOUR}
Pop ${_MINUTE}
Pop ${_SECOND}
!macroend


!define time::MathTime `!insertmacro time::MathTime`

!macro time::MathTime _EXPRESSION _ERR
time::_MathTime /NOUNLOAD `${_EXPRESSION}`
Pop ${_ERR}
!macroend


!define time::Unload `!insertmacro time::Unload`

!macro time::Unload
time::_Unload
!macroend
84 changes: 84 additions & 0 deletions Include/VersionCompare.nsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
Function VersionCompare
!define VersionCompare `!insertmacro VersionCompareCall`

!macro VersionCompareCall _VER1 _VER2 _RESULT
Push `${_VER1}`
Push `${_VER2}`
Call VersionCompare
Pop ${_RESULT}
!macroend

Exch $1
Exch
Exch $0
Exch
Push $2
Push $3
Push $4
Push $5
Push $6
Push $7

begin:
StrCpy $2 -1
IntOp $2 $2 + 1
StrCpy $3 $0 1 $2
StrCmp $3 '' +2
StrCmp $3 '.' 0 -3
StrCpy $4 $0 $2
IntOp $2 $2 + 1
StrCpy $0 $0 '' $2

StrCpy $2 -1
IntOp $2 $2 + 1
StrCpy $3 $1 1 $2
StrCmp $3 '' +2
StrCmp $3 '.' 0 -3
StrCpy $5 $1 $2
IntOp $2 $2 + 1
StrCpy $1 $1 '' $2

StrCmp $4$5 '' equal

StrCpy $6 -1
IntOp $6 $6 + 1
StrCpy $3 $4 1 $6
StrCmp $3 '0' -2
StrCmp $3 '' 0 +2
StrCpy $4 0

StrCpy $7 -1
IntOp $7 $7 + 1
StrCpy $3 $5 1 $7
StrCmp $3 '0' -2
StrCmp $3 '' 0 +2
StrCpy $5 0

StrCmp $4 0 0 +2
StrCmp $5 0 begin newer2
StrCmp $5 0 newer1
IntCmp $6 $7 0 newer1 newer2

StrCpy $4 '1$4'
StrCpy $5 '1$5'
IntCmp $4 $5 begin newer2 newer1

equal:
StrCpy $0 0
goto end
newer1:
StrCpy $0 1
goto end
newer2:
StrCpy $0 2

end:
Pop $7
Pop $6
Pop $5
Pop $4
Pop $3
Pop $2
Pop $1
Exch $0
FunctionEnd
Loading

0 comments on commit 5140435

Please sign in to comment.