Add progress dialog

This commit is contained in:
Xpl0itU 2023-07-18 17:50:11 +02:00
parent cb0510931e
commit f8a15b1d5b
7 changed files with 170 additions and 32 deletions

View file

@ -11,15 +11,42 @@ package wiiudownloader
import "C"
import (
"fmt"
"sync"
"time"
"unsafe"
)
func decryptContents(path string) error {
argv := make([]*C.char, 2)
argv[0] = C.CString("WiiUDownloader")
argv[1] = C.CString(path)
if int(C.cdecrypt_main(2, (**C.char)(unsafe.Pointer(&argv[0])))) != 0 {
var (
wg sync.WaitGroup
decryptionDone = false
decryptionError = false
)
func decryptContents(path string, progress *int) error {
wg.Add(1)
go runDecryption(path, progress)
for !decryptionDone {
fmt.Println(*progress)
time.Sleep(500 * time.Millisecond)
}
wg.Wait()
if decryptionError {
decryptionDone = false
decryptionError = false
return fmt.Errorf("decryption failed")
}
return nil
}
func runDecryption(path string, progress *int) {
defer wg.Done()
argv := make([]*C.char, 2)
argv[0] = C.CString("WiiUDownloader")
argv[1] = C.CString(path)
if int(C.cdecrypt_main(2, (**C.char)(unsafe.Pointer(&argv[0])), (*C.int)(unsafe.Pointer(progress)))) != 0 {
decryptionError = true
}
decryptionDone = true
}