mirror of
https://github.com/Xpl0itU/WiiUDownloader.git
synced 2025-05-09 13:52:02 -04:00
Add progress dialog
This commit is contained in:
parent
cb0510931e
commit
f8a15b1d5b
7 changed files with 170 additions and 32 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue