diff options
| author | Mary <me@thog.eu> | 2021-11-28 21:24:17 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-28 21:24:17 +0100 |
| commit | 57d3296ba4e5c1fc7ca30376c7ca8eb3041ae2f6 (patch) | |
| tree | 02e17606a847ff11f68bc7bf123e882f87055b52 /Ryujinx.Graphics.Gpu/Shader/Cache/CacheCollection.cs | |
| parent | 7b040e51b078a16e979ad962ba1265f3be4bcb1d (diff) | |
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 <caianbene@gmail.com>
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Shader/Cache/CacheCollection.cs')
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Shader/Cache/CacheCollection.cs | 24 |
1 files changed, 17 insertions, 7 deletions
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 /// <summary> /// Main storage of the cache collection. /// </summary> - private ZipArchive _cacheArchive; + private ZipFile _cacheArchive; /// <summary> /// 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())); } /// <summary> @@ -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(); |
