WiiUDownloader/utils.go
Xpl0itU e40d499b72
Port title database and cdecrypt to Go (#87)
* Experimental removal of cdecrypt

* Pushing before cdecrypt port

* Some progress...

* Replace title database with native Go

* Update title db url

* Almost working decryption and extraction

* Almost there

* Remove unnecessary type conversion

* Fix directory structure creation

* Finally fix decryption

* Cleanup print statements

* Do not write FST to file

* Add progress

* Add encrypted contents decryption
2024-03-31 19:38:13 +02:00

33 lines
640 B
Go

package wiiudownloader
import (
"cmp"
"os"
"path/filepath"
"strings"
)
func min[T cmp.Ordered](a, b T) T {
if a < b {
return a
}
return b
}
func isThisDecryptedFile(path string) bool {
return strings.Contains(path, "code") || strings.Contains(path, "content") || strings.Contains(path, "meta")
}
func doDeleteEncryptedContents(path string) error {
return filepath.Walk(path, func(filePath string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if info.Mode().IsRegular() && !isThisDecryptedFile(filePath) {
if err := os.Remove(filePath); err != nil {
return err
}
}
return nil
})
}