Add archive check for extracting files with illegal characters
This commit is contained in:
parent
d2db5c1c68
commit
be19e8e2e2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,8 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Switch_Toolbox.Library.IO
|
||||
{
|
||||
@ -15,5 +16,13 @@ namespace Switch_Toolbox.Library.IO
|
||||
// swap adjacent 8-bit blocks
|
||||
return ((x & 0xFF00FF00) >> 8) | ((x & 0x00FF00FF) << 8);
|
||||
}
|
||||
|
||||
public static string RemoveIllegaleCharacters(this string str)
|
||||
{
|
||||
string illegal = "\"M\"\\a/ry/ h**ad:>> a\\/:*?\"| li*tt|le|| la\"mb.?";
|
||||
Regex r = new Regex(string.Format("[{0}]", Regex.Escape(str)));
|
||||
illegal = r.Replace(illegal, "");
|
||||
return illegal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,9 +40,11 @@ namespace Switch_Toolbox.Library
|
||||
|
||||
public virtual void Replace()
|
||||
{
|
||||
string fileName = Path.GetFileName(FileName.RemoveIllegaleCharacters());
|
||||
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.FileName = FileName;
|
||||
ofd.DefaultExt = Path.GetExtension(FileName);
|
||||
ofd.FileName = fileName;
|
||||
ofd.DefaultExt = Path.GetExtension(fileName);
|
||||
ofd.Filter = "Raw Data (*.*)|*.*";
|
||||
|
||||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
@ -53,7 +55,7 @@ namespace Switch_Toolbox.Library
|
||||
|
||||
public virtual void Export()
|
||||
{
|
||||
string fileName = Path.GetFileName(FileName);
|
||||
string fileName = Path.GetFileName(FileName.RemoveIllegaleCharacters());
|
||||
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.FileName = fileName;
|
||||
@ -249,6 +251,7 @@ namespace Switch_Toolbox.Library
|
||||
}
|
||||
|
||||
|
||||
|
||||
FolderSelectDialog folderDialog = new FolderSelectDialog();
|
||||
if (folderDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
@ -268,6 +271,7 @@ namespace Switch_Toolbox.Library
|
||||
{
|
||||
string FilePath = ((ArchiveNodeWrapper)file).ArchiveFileInfo.FileName;
|
||||
FilePath = FilePath.Replace(ParentPath, string.Empty);
|
||||
FilePath = FilePath.RemoveIllegaleCharacters();
|
||||
|
||||
Console.WriteLine($"FilePath " + FilePath);
|
||||
var path = Path.Combine(folderDialog.SelectedPath, FilePath);
|
||||
|
@ -187,6 +187,7 @@ namespace Switch_Toolbox.Library
|
||||
f.Add(format);
|
||||
return GetAllFilters(f);
|
||||
}
|
||||
|
||||
public static string GetAllFilters(IEnumerable<IFileFormat> format)
|
||||
{
|
||||
var alltypes = format;
|
||||
|
Loading…
Reference in New Issue
Block a user