From 57d3296ba4e5c1fc7ca30376c7ca8eb3041ae2f6 Mon Sep 17 00:00:00 2001 From: Mary Date: Sun, 28 Nov 2021 21:24:17 +0100 Subject: infra: Migrate to .NET 6 (#2829) * infra: Migrate to .NET 6 * Rollback version naming change * Workaround .NET 6 ZipArchive API issues * ci: Switch to VS 2022 for AppVeyor CI is now ready for .NET 6 * Suppress WebClient warning in DoUpdateWithMultipleThreads * Attempt to workaround System.Drawing.Common changes on 6.0.0 * Change keyboard rendering from System.Drawing to ImageSharp * Make the software keyboard renderer multithreaded * Bump ImageSharp version to 1.0.4 to fix a bug in Image.Load * Add fallback fonts to the keyboard renderer * Fix warnings * Address caian's comment * Clean up linux workaround as it's uneeded now * Update readme Co-authored-by: Caian Benedicto --- .../Shader/Cache/CacheCollection.cs | 24 +++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'Ryujinx.Graphics.Gpu/Shader/Cache/CacheCollection.cs') diff --git a/Ryujinx.Graphics.Gpu/Shader/Cache/CacheCollection.cs b/Ryujinx.Graphics.Gpu/Shader/Cache/CacheCollection.cs index 316e027f..a98531f6 100644 --- a/Ryujinx.Graphics.Gpu/Shader/Cache/CacheCollection.cs +++ b/Ryujinx.Graphics.Gpu/Shader/Cache/CacheCollection.cs @@ -1,11 +1,11 @@ -using Ryujinx.Common; +using ICSharpCode.SharpZipLib.Zip; +using Ryujinx.Common; using Ryujinx.Common.Logging; using Ryujinx.Graphics.Gpu.Shader.Cache.Definition; using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; -using System.IO.Compression; using System.Linq; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -119,7 +119,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache /// /// Main storage of the cache collection. /// - private ZipArchive _cacheArchive; + private ZipFile _cacheArchive; /// /// Indicates if the cache collection supports modification. @@ -324,7 +324,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache EnsureArchiveUpToDate(); // Open the zip in readonly to avoid anyone modifying/corrupting it during normal operations. - _cacheArchive = ZipFile.Open(GetArchivePath(), ZipArchiveMode.Read); + _cacheArchive = new ZipFile(File.OpenRead(GetArchivePath())); } /// @@ -336,7 +336,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache // First close previous opened instance if found. if (_cacheArchive != null) { - _cacheArchive.Dispose(); + _cacheArchive.Close(); } string archivePath = GetArchivePath(); @@ -355,8 +355,18 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache return; } + if (!File.Exists(archivePath)) + { + using (ZipFile newZip = ZipFile.Create(archivePath)) + { + // Workaround for SharpZipLib issue #395 + newZip.BeginUpdate(); + newZip.CommitUpdate(); + } + } + // Open the zip in read/write. - _cacheArchive = ZipFile.Open(archivePath, ZipArchiveMode.Update); + _cacheArchive = new ZipFile(File.Open(archivePath, FileMode.Open, FileAccess.ReadWrite, FileShare.None)); Logger.Info?.Print(LogClass.Gpu, $"Updating cache collection archive {archivePath}..."); @@ -366,7 +376,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache CacheHelper.EnsureArchiveUpToDate(_cacheDirectory, _cacheArchive, _hashTable); // Close the instance to force a flush. - _cacheArchive.Dispose(); + _cacheArchive.Close(); _cacheArchive = null; string cacheTempDataPath = GetCacheTempDataPath(); -- cgit v1.2.3