diff --git a/Mirivoice.Desktop/Mirivoice.Desktop.csproj b/Mirivoice.Desktop/Mirivoice.Desktop.csproj
index 9154e39..b6731ff 100644
--- a/Mirivoice.Desktop/Mirivoice.Desktop.csproj
+++ b/Mirivoice.Desktop/Mirivoice.Desktop.csproj
@@ -23,7 +23,6 @@
-
diff --git a/Mirivoice.Desktop/Program.cs b/Mirivoice.Desktop/Program.cs
index 6618656..74a6c02 100644
--- a/Mirivoice.Desktop/Program.cs
+++ b/Mirivoice.Desktop/Program.cs
@@ -3,6 +3,7 @@
using Mirivoice.Mirivoice.Core;
using Serilog;
using System;
+using System.IO;
using System.Text;
namespace Mirivoice.Desktop;
@@ -19,7 +20,7 @@ public static void Main(string[] args)
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
InitLogging();
- initMirivoice();
+ InitMirivoice();
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
}
@@ -49,7 +50,7 @@ public static void InitLogging()
Log.Information("Logging initialized.");
}
- public static void initMirivoice()
+ public static void InitMirivoice()
{
Log.Information("Mirivoice init");
@@ -57,4 +58,6 @@ public static void initMirivoice()
}
+
+
}
diff --git a/Mirivoice/Assets/DefaultVoicers/Miri.z01 b/Mirivoice/Assets/DefaultVoicers/Miri.z01
new file mode 100644
index 0000000..37ea3f1
Binary files /dev/null and b/Mirivoice/Assets/DefaultVoicers/Miri.z01 differ
diff --git a/Mirivoice/Assets/DefaultVoicers/Miri.zip b/Mirivoice/Assets/DefaultVoicers/Miri.zip
new file mode 100644
index 0000000..f357bd2
Binary files /dev/null and b/Mirivoice/Assets/DefaultVoicers/Miri.zip differ
diff --git a/Mirivoice/Mirivoice.Core/Managers/MainManager.cs b/Mirivoice/Mirivoice.Core/Managers/MainManager.cs
index c9d0110..389b50c 100644
--- a/Mirivoice/Mirivoice.Core/Managers/MainManager.cs
+++ b/Mirivoice/Mirivoice.Core/Managers/MainManager.cs
@@ -2,10 +2,14 @@
using Mirivoice.Mirivoice.Core.Managers;
using Mirivoice.Mirivoice.Core.Utils;
using Serilog;
+using System;
using System.Collections.ObjectModel;
using System.IO;
using System.Threading.Tasks;
+using SharpCompress;
using VYaml.Serialization;
+using SharpCompress.Archives;
+
namespace Mirivoice.Mirivoice.Core
{
@@ -32,6 +36,7 @@ public class MainManager : SingletonBase
public void Initialize()
{
CheckDirs();
+ UpdateDefaultVoicers();
LoadVoicerManager();
LoadSetting();
InitializationTask = Task.Run(() => {
@@ -57,8 +62,60 @@ public void LoadSetting()
Setting.Save();
}
}
+ private static void DeleteExtractedZip(string zipFilePath)
+ {
+ // deletes zip file and split files
+ string baseFileName = Path.GetFileNameWithoutExtension(zipFilePath);
+ string directory = Path.GetDirectoryName(zipFilePath);
+
+ // delete zip file
+ if (File.Exists(zipFilePath))
+ {
+ File.Delete(zipFilePath);
+ Console.WriteLine($"Deleted: {zipFilePath}");
+ }
+
+ // delete split files
+ int index = 1;
+ while (true)
+ {
+ string splitFilePath = Path.Combine(directory, $"{baseFileName}.z{index:D2}");
+ if (File.Exists(splitFilePath))
+ {
+ File.Delete(splitFilePath);
+ index++;
+ }
+ else
+ {
+ break;
+ }
+ }
+ }
+ public void UpdateDefaultVoicers()
+ {
+ Log.Information("Updating default voicers.");
+ string dirName = Path.Combine(MainManager.Instance.PathM.AssetsPath, "DefaultVoicers");
+ if (Directory.Exists(dirName))
+ {
+ foreach (string file in Directory.GetFiles(dirName))
+ {
+ if (Path.GetExtension(file).Equals(".zip", StringComparison.OrdinalIgnoreCase))
+ {
+ try
+ {
+ ExtractSplitZip(file, PathM.VoicerPath);
+ Log.Information($"Successfully extracted {file}.");
+ }
+ catch (Exception ex)
+ {
+ Log.Error($"Error extracting {file}: {ex.Message}");
+ }
+ }
+ }
+ }
+ }
+
-
public string ReadTxtFile(string txtPath)
{
@@ -95,7 +152,32 @@ public static void CheckDirs()
}
}
+ public static void ExtractSplitZip(string zipFilePath, string extractPath)
+ {
+ using (var archive = ArchiveFactory.Open(zipFilePath))
+ {
+ foreach (var entry in archive.Entries)
+ {
+ if (!entry.IsDirectory)
+ {
+ string entryPath = Path.Combine(extractPath, entry.Key);
+
+ string directoryPath = Path.GetDirectoryName(entryPath);
+ if (!string.IsNullOrEmpty(directoryPath))
+ {
+ Directory.CreateDirectory(directoryPath);
+ }
+
+ using (var stream = File.OpenWrite(entryPath))
+ {
+ entry.WriteTo(stream);
+ }
+ }
+ }
+ }
+ DeleteExtractedZip(zipFilePath);
+ }
}
diff --git a/Mirivoice/Mirivoice.Core/Managers/PathManager.cs b/Mirivoice/Mirivoice.Core/Managers/PathManager.cs
index c088a9d..8cf2ffe 100644
--- a/Mirivoice/Mirivoice.Core/Managers/PathManager.cs
+++ b/Mirivoice/Mirivoice.Core/Managers/PathManager.cs
@@ -13,13 +13,14 @@ public class PathManager
public string DataPath { get; private set; }
public string CachePath { get; private set; }
public string SettingsPath { get; private set; }
+
public string RecentFilesPath { get; private set; }
public bool HomePathIsAscii { get; private set; }
public bool IsInstalled { get; private set; }
public string LogFilePath => Path.Combine(DataPath, "Logs", "log.txt");
public string VoicerPath => Path.Combine(RootPath, "Voicers");
-
+ public string AssetsPath => Path.Combine(RootPath, "Assets");
public PathManager()
{
diff --git a/Mirivoice/Mirivoice.csproj b/Mirivoice/Mirivoice.csproj
index f94a082..a907598 100644
--- a/Mirivoice/Mirivoice.csproj
+++ b/Mirivoice/Mirivoice.csproj
@@ -54,6 +54,12 @@
+
+
+ PreserveNewest
+
+
+
@@ -96,6 +102,8 @@
+
+
LineBoxView.axaml