Skip to content

Commit

Permalink
Merge pull request #68 from Xanfre/master
Browse files Browse the repository at this point in the history
Use the encoding for the current OEM code page when reading zips
  • Loading branch information
FenPhoenix authored Feb 21, 2021
2 parents 9f44ff1 + fa83716 commit cf8dd2f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
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

0 comments on commit cf8dd2f

Please sign in to comment.