Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the encoding for the current OEM code page when reading zips #68

Merged
merged 1 commit into from
Feb 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions AngelLoader/FMBackupAndRestore.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
Expand Down Expand Up @@ -278,7 +279,7 @@ void AddBakFilesFrom(string path)
string fmInstalledPath = Path.Combine(thisFMInstallsBasePath, fm.InstalledDir);

using (var archive = new ZipArchive(new FileStream(fileToUse.Name, FileMode.Open, FileAccess.Read),
ZipArchiveMode.Read, leaveOpen: false))
ZipArchiveMode.Read, leaveOpen: false, Encoding.GetEncoding(CultureInfo.CurrentCulture.TextInfo.OEMCodePage)))
{
int filesCount = archive.Entries.Count;
if (fileToUse.DarkLoader)
Expand Down Expand Up @@ -490,7 +491,7 @@ private static (List<string> ChangedList, List<string> AddedList, List<string> F
if (fmIsZip)
{
using var archive = new ZipArchive(new FileStream(fmArchivePath, FileMode.Open, FileAccess.Read),
ZipArchiveMode.Read, leaveOpen: false);
ZipArchiveMode.Read, leaveOpen: false, Encoding.GetEncoding(CultureInfo.CurrentCulture.TextInfo.OEMCodePage));

for (int i = 0; i < archive.Entries.Count; i++)
{
Expand Down
8 changes: 6 additions & 2 deletions AngelLoader/FMCache.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AngelLoader.DataClasses;
using AngelLoader.WinAPI;
Expand Down Expand Up @@ -214,7 +216,8 @@ private static void ExtractHTMLRefFiles(string fmArchivePath, string fmCachePath
var htmlRefFiles = new List<NameAndIndex>();

using var archive = new ZipArchive(new FileStream(fmArchivePath, FileMode.Open, FileAccess.Read),
ZipArchiveMode.Read, leaveOpen: false);
ZipArchiveMode.Read, leaveOpen: false,
Encoding.GetEncoding(CultureInfo.CurrentCulture.TextInfo.OEMCodePage));

foreach (string f in Directory.GetFiles(fmCachePath, "*", SearchOption.AllDirectories))
{
Expand Down Expand Up @@ -300,7 +303,8 @@ private static void ZipExtract(string fmArchivePath, string fmCachePath, List<st
try
{
using var archive = new ZipArchive(new FileStream(fmArchivePath, FileMode.Open, FileAccess.Read),
ZipArchiveMode.Read, leaveOpen: false);
ZipArchiveMode.Read, leaveOpen: false,
Encoding.GetEncoding(CultureInfo.CurrentCulture.TextInfo.OEMCodePage));

for (int i = 0; i < archive.Entries.Count; i++)
{
Expand Down
4 changes: 3 additions & 1 deletion AngelLoader/FMInstallAndPlay.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Text;
Expand Down Expand Up @@ -606,7 +607,8 @@ private static bool InstallFMZip(string fmArchivePath, string fmInstalledPath)
Directory.CreateDirectory(fmInstalledPath);

using var archive = new ZipArchive(new FileStream(fmArchivePath, FileMode.Open, FileAccess.Read),
ZipArchiveMode.Read, leaveOpen: false);
ZipArchiveMode.Read, leaveOpen: false,
Encoding.GetEncoding(CultureInfo.CurrentCulture.TextInfo.OEMCodePage));

int filesCount = archive.Entries.Count;
for (int i = 0; i < filesCount; i++)
Expand Down