diff --git a/PCK-Studio/Classes/FileTypes/Binka.cs b/PCK-Studio/Classes/FileTypes/Binka.cs
index 26776e15..a5c25ae3 100644
--- a/PCK-Studio/Classes/FileTypes/Binka.cs
+++ b/PCK-Studio/Classes/FileTypes/Binka.cs
@@ -2,22 +2,18 @@
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
-using System.Web.Caching;
-using PckStudio.Classes.Misc;
using SharpMSS;
namespace PckStudio.Classes
{
internal static class Binka
{
- private static FileCacher cacher = new FileCacher(Program.AppDataCache);
-
public static int FromWav(string inputFilepath, string outputFilepath, int compressionLevel)
{
- cacher.Cache(Properties.Resources.binka_encode, "binka_encode.exe");
+ ApplicationScope.AppDataCacher.Cache(Properties.Resources.binka_encode, "binka_encode.exe");
var process = Process.Start(new ProcessStartInfo
{
- FileName = cacher.GetCachedFilepath("binka_encode.exe"),
+ FileName = ApplicationScope.AppDataCacher.GetCachedFilepath("binka_encode.exe"),
Arguments = $"\"{inputFilepath}\" \"{outputFilepath}\" -s -b{compressionLevel}",
UseShellExecute = true,
CreateNoWindow = true,
@@ -34,16 +30,16 @@ namespace PckStudio.Classes
throw new Exception("Not a Bink Audio file.");
}
- cacher.Cache(Properties.Resources.mss32, "mss32.dll");
- cacher.Cache(Properties.Resources.binkawin, "binkawin.asi");
+ ApplicationScope.AppDataCacher.Cache(Properties.Resources.mss32, "mss32.dll");
+ ApplicationScope.AppDataCacher.Cache(Properties.Resources.binkawin, "binkawin.asi");
- LibHandle mss32LibHandle = new LibHandle(cacher.GetCachedFilepath("mss32.dll"));
+ LibHandle mss32LibHandle = new LibHandle(ApplicationScope.AppDataCacher.GetCachedFilepath("mss32.dll"));
string destinationFilepath = Path.Combine(
Path.GetDirectoryName(outputFilepath),
Path.GetFileNameWithoutExtension(inputFilepath) + ".wav");
- AILAPI.SetRedistDirectory(cacher.CacheDirectory.Replace('\\', '/'));
+ AILAPI.SetRedistDirectory(ApplicationScope.AppDataCacher.CacheDirectory.Replace('\\', '/'));
RIBAPI.LoadApplicationProviders("*.asi");
diff --git a/PCK-Studio/Internals/ApplicationScope.cs b/PCK-Studio/Internals/ApplicationScope.cs
new file mode 100644
index 00000000..18b154eb
--- /dev/null
+++ b/PCK-Studio/Internals/ApplicationScope.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using PckStudio.Classes.Misc;
+
+namespace PckStudio
+{
+ internal static class ApplicationScope
+ {
+ public static FileCacher AppDataCacher = new FileCacher(Program.AppDataCache);
+
+ }
+}
diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs
index 98fa0654..5c6ad36e 100644
--- a/PCK-Studio/MainForm.cs
+++ b/PCK-Studio/MainForm.cs
@@ -2249,18 +2249,18 @@ namespace PckStudio
waitDiag.Show(this);
int convertedCounter = 0;
- foreach (string file in fileDialog.FileNames)
+ foreach (string waveFilepath in fileDialog.FileNames)
{
- string[] a = Path.GetFileNameWithoutExtension(file).Split(Path.GetInvalidFileNameChars());
+ string[] a = Path.GetFileNameWithoutExtension(waveFilepath).Split(Path.GetInvalidFileNameChars());
string songName = string.Join("_", a);
songName = System.Text.RegularExpressions.Regex.Replace(songName, @"[^\u0000-\u007F]+", "_"); // Replace UTF characters
- string cacheSongLoc = Path.Combine(Program.AppDataCache, songName + Path.GetExtension(file));
+ string cacheSongLoc = Path.Combine(ApplicationScope.AppDataCacher.CacheDirectory, songName + Path.GetExtension(waveFilepath));
if (File.Exists(cacheSongLoc))
File.Delete(cacheSongLoc);
- using (var reader = new NAudio.Wave.WaveFileReader(file)) //read from original location
+ using (var reader = new NAudio.Wave.WaveFileReader(waveFilepath)) //read from original location
{
var newFormat = new NAudio.Wave.WaveFormat(reader.WaveFormat.SampleRate, 16, reader.WaveFormat.Channels);
using (var conversionStream = new NAudio.Wave.WaveFormatConversionStream(newFormat, reader))
@@ -2274,7 +2274,7 @@ namespace PckStudio
int exitCode = 0;
await System.Threading.Tasks.Task.Run(() =>
{
- exitCode = Classes.Binka.FromWav(cacheSongLoc, Path.Combine(Path.GetDirectoryName(file), Path.GetFileNameWithoutExtension(file) + ".binka"), 4);
+ exitCode = Classes.Binka.FromWav(cacheSongLoc, Path.Combine(Path.GetDirectoryName(waveFilepath), Path.GetFileNameWithoutExtension(waveFilepath) + ".binka"), 4);
});
if (exitCode != 0)
diff --git a/PCK-Studio/PckStudio.csproj b/PCK-Studio/PckStudio.csproj
index 2217e60c..50cc2cb4 100644
--- a/PCK-Studio/PckStudio.csproj
+++ b/PCK-Studio/PckStudio.csproj
@@ -192,6 +192,7 @@
+