added database to store metadata
This commit is contained in:
@@ -6,16 +6,31 @@ public static class PathHelper
|
||||
{
|
||||
public static readonly IOPath DATA_DIR = "data";
|
||||
public static readonly IOPath SAVES_DIR = Path.Concat(DATA_DIR, "saves");
|
||||
public static readonly IOPath PARSED_DIR = Path.Concat(DATA_DIR, "parsed");
|
||||
public static readonly IOPath TEMP_DIR = "temp";
|
||||
|
||||
public static IOPath GetMetaFilePath(string save_id) => Path.Concat(SAVES_DIR, save_id + ".meta.json");
|
||||
|
||||
public static IOPath GetSaveFilePath(string save_id) => Path.Concat(SAVES_DIR, save_id + ".eu4");
|
||||
|
||||
public static IOPath GetParsedSaveFilePath(string save_id) => Path.Concat(SAVES_DIR, save_id + ".parsed.json");
|
||||
|
||||
public static void CreateProgramDirectories()
|
||||
{
|
||||
Directory.Create(DATA_DIR);
|
||||
Directory.Create(SAVES_DIR);
|
||||
Directory.Create(PARSED_DIR);
|
||||
Directory.Create(TEMP_DIR);
|
||||
}
|
||||
|
||||
public static void CleanTempDirectory()
|
||||
{
|
||||
Directory.Delete(TEMP_DIR);
|
||||
Directory.Create(TEMP_DIR);
|
||||
}
|
||||
|
||||
public static Stream CreateTempFile()
|
||||
{
|
||||
string fileName = Guid.NewGuid().ToString();
|
||||
IOPath filePath = Path.Concat(TEMP_DIR, fileName);
|
||||
var stream = System.IO.File.Open(filePath.Str, FileMode.CreateNew, FileAccess.ReadWrite,
|
||||
FileShare.Read | FileShare.Delete);
|
||||
// file stays as a ghost until it is closed
|
||||
File.Delete(filePath);
|
||||
return stream;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user