fix: cache mkdir

I originally left it out because I wanted to avoid unnecessary
code duplication. Turns out it wasn't unnecessary.
This commit is contained in:
あかニャン 2024-08-24 14:14:02 +00:00
parent 07ee892b43
commit 032b6864da
2 changed files with 9 additions and 3 deletions

View File

@ -12,7 +12,9 @@ class patch_OperationManager: OperationManager {
~patch_OperationManager() {
try {
File.WriteAllText(_fileName, MovieIndex.ToString());
} catch(Exception) { }
} catch(Exception ex) {
System.Console.WriteLine(ex);
}
}
public int MovieIndex {
set {
@ -41,7 +43,9 @@ class patch_OperationManager: OperationManager {
orig_initialize();
using IniFile iniFile = new("mu3.ini");
_fileName = Path.Combine(iniFile.getValue("Extra", "CacheDir", "."), "data_advert_cache.txt");
var dir = iniFile.getValue("Extra", "CacheDir", ".");
Directory.CreateDirectory(dir);
_fileName = Path.Combine(dir, "data_advert_cache.txt");
try {
_movieIndex = Math.Max(0, int.Parse(File.ReadAllText(_fileName)));

View File

@ -13,7 +13,9 @@ public class patch_DataStudioManager: DataStudioManager {
private static void initCache() {
using IniFile iniFile = new("mu3.ini");
_fileName = Path.Combine(iniFile.getValue("Extra", "CacheDir", "."), "data_cache.bin");
var dir = iniFile.getValue("Extra", "CacheDir", ".");
Directory.CreateDirectory(dir);
_fileName = Path.Combine(dir, "data_cache.bin");
if(File.Exists(_fileName)) {
System.Console.WriteLine("Loading data cache...");