updates bundled dlls if outdated

This commit is contained in:
aomizu
2025-06-08 11:28:35 +09:00
parent 3460969409
commit 90fa1e7677
3 changed files with 57 additions and 1 deletions

View File

@@ -38,6 +38,19 @@ func PatchTurtleWoW(myWindow fyne.Window, updateAllStatuses func()) {
for resourceName, destPath := range filesToCopy { for resourceName, destPath := range filesToCopy {
log.Printf("Processing resource: %s to %s", resourceName, destPath) log.Printf("Processing resource: %s to %s", resourceName, destPath)
// Check if file already exists and has correct size
if utils.PathExists(destPath) && utils.CompareFileWithBundledResource(destPath, resourceName) {
log.Printf("File %s already exists with correct size, skipping copy", destPath)
continue
}
if utils.PathExists(destPath) {
log.Printf("File %s exists but has incorrect size, updating...", destPath)
} else {
log.Printf("File %s does not exist, creating...", destPath)
}
resource, err := fyne.LoadResourceFromPath(resourceName) resource, err := fyne.LoadResourceFromPath(resourceName)
if err != nil { if err != nil {
errMsg := fmt.Sprintf("failed to open bundled resource %s: %v", resourceName, err) errMsg := fmt.Sprintf("failed to open bundled resource %s: %v", resourceName, err)

View File

@@ -92,9 +92,18 @@ func updateTurtleWoWStatus() {
} }
} }
// Check if patched files have the correct size (matches bundled versions)
winerosettaDllCorrectSize := utils.CompareFileWithBundledResource(winerosettaDllPath, "winerosetta/winerosetta.dll")
d3d9DllCorrectSize := utils.CompareFileWithBundledResource(d3d9DllPath, "winerosetta/d3d9.dll")
libSiliconPatchCorrectSize := utils.CompareFileWithBundledResource(libSiliconPatchDllPath, "winerosetta/libSiliconPatch.dll")
rosettaX87CorrectSize := utils.CompareFileWithBundledResource(rosettaX87ExePath, "rosettax87/rosettax87")
libRuntimeRosettaX87CorrectSize := utils.CompareFileWithBundledResource(libRuntimeRosettaX87Path, "rosettax87/libRuntimeRosettax87")
if utils.PathExists(winerosettaDllPath) && utils.PathExists(d3d9DllPath) && utils.PathExists(libSiliconPatchDllPath) && if utils.PathExists(winerosettaDllPath) && utils.PathExists(d3d9DllPath) && utils.PathExists(libSiliconPatchDllPath) &&
utils.DirExists(rosettaX87DirPath) && utils.PathExists(rosettaX87ExePath) && utils.DirExists(rosettaX87DirPath) && utils.PathExists(rosettaX87ExePath) &&
utils.PathExists(libRuntimeRosettaX87Path) && dllsFileValid { utils.PathExists(libRuntimeRosettaX87Path) && dllsFileValid &&
winerosettaDllCorrectSize && d3d9DllCorrectSize && libSiliconPatchCorrectSize &&
rosettaX87CorrectSize && libRuntimeRosettaX87CorrectSize {
paths.PatchesAppliedTurtleWoW = true paths.PatchesAppliedTurtleWoW = true
} }
} }

View File

@@ -138,3 +138,37 @@ func CheckForUpdate(currentVersion string) (latestVersion, releaseNotes string,
latest := strings.TrimPrefix(data.TagName, "v") latest := strings.TrimPrefix(data.TagName, "v")
return latest, data.Body, latest != currentVersion, nil return latest, data.Body, latest != currentVersion, nil
} }
// GetBundledResourceSize returns the size of a bundled resource
func GetBundledResourceSize(resourcePath string) (int64, error) {
resource, err := fyne.LoadResourceFromPath(resourcePath)
if err != nil {
return 0, fmt.Errorf("failed to load bundled resource %s: %v", resourcePath, err)
}
return int64(len(resource.Content())), nil
}
// CompareFileWithBundledResource compares the size of a file with a bundled resource
func CompareFileWithBundledResource(filePath, resourcePath string) bool {
if !PathExists(filePath) {
return false
}
// Get file size
fileInfo, err := os.Stat(filePath)
if err != nil {
log.Printf("Failed to get file info for %s: %v", filePath, err)
return false
}
fileSize := fileInfo.Size()
// Get bundled resource size
resourceSize, err := GetBundledResourceSize(resourcePath)
if err != nil {
log.Printf("Failed to get bundled resource size for %s: %v", resourcePath, err)
return false
}
log.Printf("Comparing file sizes: %s (%d bytes) vs %s (%d bytes)", filePath, fileSize, resourcePath, resourceSize)
return fileSize == resourceSize
}