mirror of
https://github.com/whoswhip/RhythiaReplayExporter.git
synced 2026-12-04 07:08:42 +00:00
fix: use local app data on linux; try "Rhythia" as well
This commit is contained in:
+22
-8
@@ -1,12 +1,18 @@
|
|||||||
using Microsoft.Data.Sqlite;
|
using System.Globalization;
|
||||||
using System.Globalization;
|
using System.Runtime.InteropServices;
|
||||||
|
using Microsoft.Data.Sqlite;
|
||||||
|
|
||||||
namespace RhythiaReplayExporter;
|
namespace RhythiaReplayExporter;
|
||||||
|
|
||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
string appData;
|
||||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||||
|
appData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
||||||
|
else
|
||||||
|
appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||||
if (string.IsNullOrWhiteSpace(appData))
|
if (string.IsNullOrWhiteSpace(appData))
|
||||||
{
|
{
|
||||||
Console.WriteLine("Failed to find app data folder.");
|
Console.WriteLine("Failed to find app data folder.");
|
||||||
@@ -17,9 +23,13 @@ class Program
|
|||||||
string rhythia = Path.Combine(appData, "CapoRhythia");
|
string rhythia = Path.Combine(appData, "CapoRhythia");
|
||||||
if (!Directory.Exists(rhythia))
|
if (!Directory.Exists(rhythia))
|
||||||
{
|
{
|
||||||
Console.WriteLine("CapoRhythia directory doesn't exist in app data.");
|
rhythia = Path.Combine(appData, "Rhythia");
|
||||||
Environment.Exit(1);
|
if (!Directory.Exists(rhythia))
|
||||||
return;
|
{
|
||||||
|
Console.WriteLine("Neither CapoRhythia or Rhythia exists in app data.");
|
||||||
|
Environment.Exit(1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string database = Path.Combine(rhythia, "rhythia.db");
|
string database = Path.Combine(rhythia, "rhythia.db");
|
||||||
@@ -34,7 +44,7 @@ class Program
|
|||||||
string replaysDir = Path.Combine(workingDir, "replays");
|
string replaysDir = Path.Combine(workingDir, "replays");
|
||||||
if (args.Length > 0)
|
if (args.Length > 0)
|
||||||
replaysDir = args[0];
|
replaysDir = args[0];
|
||||||
|
|
||||||
Directory.CreateDirectory(replaysDir);
|
Directory.CreateDirectory(replaysDir);
|
||||||
|
|
||||||
using SqliteConnection con = new($"Data Source={database}");
|
using SqliteConnection con = new($"Data Source={database}");
|
||||||
@@ -47,7 +57,11 @@ class Program
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
while (reader.Read())
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
DateTime createdAt = DateTime.ParseExact(reader.GetString(0), "yyyy-MM-dd HH:mm:ss.FFFFFFF", CultureInfo.InvariantCulture);
|
DateTime createdAt = DateTime.ParseExact(
|
||||||
|
reader.GetString(0),
|
||||||
|
"yyyy-MM-dd HH:mm:ss.FFFFFFF",
|
||||||
|
CultureInfo.InvariantCulture
|
||||||
|
);
|
||||||
string legacyMapId = reader.GetString(1);
|
string legacyMapId = reader.GetString(1);
|
||||||
byte[] replay = reader.GetFieldValue<byte[]>(2);
|
byte[] replay = reader.GetFieldValue<byte[]>(2);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user