mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Check if the directory exists first before saving data to it
This commit is contained in:
@ -2,6 +2,8 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using Alphaleonis.Win32.Filesystem;
|
||||||
|
using Syroot.Windows.IO;
|
||||||
|
|
||||||
namespace Wabbajack.Common
|
namespace Wabbajack.Common
|
||||||
{
|
{
|
||||||
@ -84,6 +86,7 @@ namespace Wabbajack.Common
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static string HashFileExtension => ".xxHash";
|
public static string HashFileExtension => ".xxHash";
|
||||||
|
public static string LocalAppDataPath => Path.Combine(KnownFolders.LocalAppData.Path, "Wabbajack");
|
||||||
|
|
||||||
public static string WabbajackCacheLocation = "http://build.wabbajack.org/nexus_api_cache/";
|
public static string WabbajackCacheLocation = "http://build.wabbajack.org/nexus_api_cache/";
|
||||||
}
|
}
|
||||||
|
@ -913,7 +913,11 @@ namespace Wabbajack.Common
|
|||||||
{
|
{
|
||||||
var bytes = Encoding.UTF8.GetBytes(data.ToJSON());
|
var bytes = Encoding.UTF8.GetBytes(data.ToJSON());
|
||||||
var encoded = ProtectedData.Protect(bytes, Encoding.UTF8.GetBytes(key), DataProtectionScope.LocalMachine);
|
var encoded = ProtectedData.Protect(bytes, Encoding.UTF8.GetBytes(key), DataProtectionScope.LocalMachine);
|
||||||
var path = Path.Combine(KnownFolders.LocalAppData.Path, "Wabbajack", key);
|
|
||||||
|
if (!Directory.Exists(Consts.LocalAppDataPath))
|
||||||
|
Directory.CreateDirectory(Consts.LocalAppDataPath);
|
||||||
|
|
||||||
|
var path = Path.Combine(Consts.LocalAppDataPath, key);
|
||||||
File.WriteAllBytes(path, encoded);
|
File.WriteAllBytes(path, encoded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user