aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/Shader/Cache/CacheHelper.cs
diff options
context:
space:
mode:
authorMary <me@thog.eu>2020-12-13 08:46:07 +0100
committerGitHub <noreply@github.com>2020-12-13 08:46:07 +0100
commit6bc2733c1796788590c9f0114013d2e4b555e31e (patch)
treea729af2552637718fc3883108539c6da6523efd6 /Ryujinx.Graphics.Gpu/Shader/Cache/CacheHelper.cs
parent19d18662ea3ed5470898ed2b7bbb06d45f6004dd (diff)
salieri: Support read-only mode if archive is already opened (#1807)
This improves shader cache resilience when people opens another program that touch the cache.zip.
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Shader/Cache/CacheHelper.cs')
-rw-r--r--Ryujinx.Graphics.Gpu/Shader/Cache/CacheHelper.cs22
1 files changed, 22 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.Gpu/Shader/Cache/CacheHelper.cs b/Ryujinx.Graphics.Gpu/Shader/Cache/CacheHelper.cs
index d10e4671..d109f1cd 100644
--- a/Ryujinx.Graphics.Gpu/Shader/Cache/CacheHelper.cs
+++ b/Ryujinx.Graphics.Gpu/Shader/Cache/CacheHelper.cs
@@ -496,5 +496,27 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache
}
}
}
+
+ public static bool IsArchiveReadOnly(string archivePath)
+ {
+ FileInfo info = new FileInfo(archivePath);
+
+ if (!info.Exists)
+ {
+ return false;
+ }
+
+ try
+ {
+ using (FileStream stream = info.Open(FileMode.Open, FileAccess.Read, FileShare.None))
+ {
+ return false;
+ }
+ }
+ catch (IOException)
+ {
+ return true;
+ }
+ }
}
}