private static void ExtractResources()
{
if (resourcesExtracted) {
return;
}
lock (extractResourcesLock) {
if (resourcesExtracted) {
return;
}
var resourcesPath = GetAbsolutePath("Resources");
var archives = Directory.EnumerateFiles(resourcesPath, "*.zip", SearchOption.AllDirectories);
foreach (var archivePath in archives) {
var destinationPath = Path.GetDirectoryName(archivePath);
var archive = ZipFile.Open(archivePath, ZipArchiveMode.Read);
foreach (var archiveEntry in archive.Entries) {
var fullEntryPath = Path.Combine(destinationPath, archiveEntry.FullName);
var fileInfo = new FileInfo(fullEntryPath);
if (fileInfo.Exists) {
if (fileInfo.Length != archiveEntry.Length) {
fileInfo.Delete();
} else if (fileInfo.LastWriteTimeUtc < archiveEntry.LastWriteTime.UtcDateTime) {
fileInfo.Delete();
}
}
if (!fileInfo.Exists) {
archiveEntry.ExtractToFile(fullEntryPath);
}
}
}
resourcesExtracted = true;
}
}