mirror of
https://github.com/Prof9/WfcReplay.git
synced 2026-09-07 17:45:32 -05:00
Added filename sanitizing, and blz.exe is ran from the same directory as the executable now. Fixes #1 and fixes #5.
This commit is contained in:
@@ -6,12 +6,13 @@ using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace WfcReplay
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static string version = "v0.3";
|
||||
static string version = "v0.4";
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
@@ -37,6 +38,7 @@ namespace WfcReplay
|
||||
MemoryStream outStream = new MemoryStream(Encoding.UTF8.GetBytes(code));
|
||||
outStream.Position = 0;
|
||||
string fileName = makeGameString(romReader) + ".txt";
|
||||
fileName = makeFileNameSafe(fileName);
|
||||
writeFile(fileName, outStream);
|
||||
Console.WriteLine("Success!");
|
||||
Console.WriteLine("Code written to " + Directory.GetCurrentDirectory() + "\\" + fileName + ".");
|
||||
@@ -109,6 +111,11 @@ namespace WfcReplay
|
||||
{
|
||||
writeFile(tempFolderPath + fileName, file);
|
||||
}
|
||||
static string makeFileNameSafe(string fileName)
|
||||
{
|
||||
string[] validParts = fileName.Split(System.IO.Path.GetInvalidFileNameChars(), StringSplitOptions.RemoveEmptyEntries);
|
||||
return string.Join("-", validParts);
|
||||
}
|
||||
|
||||
string tempFolderPath;
|
||||
|
||||
@@ -308,6 +315,7 @@ namespace WfcReplay
|
||||
writeTempFile(fileName, file);
|
||||
|
||||
ProcessStartInfo psi = new ProcessStartInfo("blz.exe", "-d " + tempFolderPath + fileName);
|
||||
psi.WorkingDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
|
||||
psi.WindowStyle = ProcessWindowStyle.Hidden;
|
||||
Process.Start(psi).WaitForExit();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user