Skip to content

Commit

Permalink
FIX version comparing
Browse files Browse the repository at this point in the history
  • Loading branch information
kimushun1101 committed Feb 4, 2024
1 parent 3255d2e commit a8bdb96
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
shell: pwsh
run: |
Compress-Archive -Path "muhenkan.exe", "${{ env.UPDATE_EXE }}", "uninstall.exe", "README.html", "LICENSE", "img" -DestinationPath "muhenkan-switch.zip"
- name: Create GitHub release
uses: actions/create-release@v1
id: create_release
Expand Down
26 changes: 19 additions & 7 deletions muhenkan.ahk
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
#Requires AutoHotkey v2.0

; 一番新しいファイルを見つける
newestUpdateExe := ""
newestModTime := 0
newestUpdateExe := A_ScriptDir "\update_v0_0_0.exe"
Loop Files, A_ScriptDir "\update*.exe"
{
currentModTime := FileGetTime(A_LoopFileFullPath, "M")
if (currentModTime > newestModTime)
{
newestModTime := currentModTime
if (VersionCompare(A_LoopFileFullPath, newestUpdateExe) > 0)
newestUpdateExe := A_LoopFileFullPath
}

; バージョン情報を比較する関数
VersionCompare(exe1, exe2)
{
v1 := StrReplace(StrReplace(exe1, A_ScriptDir "\update_v", ""), ".exe", "")
v2 := StrReplace(StrReplace(exe2, A_ScriptDir "\update_v", ""), ".exe", "")
v1Array := StrSplit(v1, "_")
v2Array := StrSplit(v2, "_")
Loop 3
{
if (v1Array[A_Index] > v2Array[A_Index])
return 1
else if (v1Array[A_Index] < v2Array[A_Index])
return -1
}
return 0
}

; バージョン違いのupdate.exe を削除
; 古いバージョンの update.exe を削除
Loop Files, A_ScriptDir "\update*.exe"
{
if A_LoopFileFullPath != newestUpdateExe
Expand Down

0 comments on commit a8bdb96

Please sign in to comment.