-
Notifications
You must be signed in to change notification settings - Fork 1
/
MoveBuildings.cs
104 lines (76 loc) · 3.02 KB
/
MoveBuildings.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
using Android.Content.Res;
using SMAPI_Installation;
using System;
using System.IO;
using System.Security.Cryptography;
using Xamarin.Android.AssemblyStore;
public static class MoveBuildings
{
private static void MoveFilesFromArm64V8aToSmapiInternal(string sourceDir)
{
try
{
string arm64V8aDir = Path.Combine(sourceDir, "smapi-internal", "arm64_v8a");
string smapiInternalDir = Path.Combine(sourceDir, "smapi-internal");
if (Directory.Exists(arm64V8aDir))
{
if (!Directory.Exists(smapiInternalDir))
{
Directory.CreateDirectory(smapiInternalDir);
}
var files = Directory.GetFiles(arm64V8aDir);
foreach (var file in files)
{
string fileName = Path.GetFileName(file);
string targetFilePath = Path.Combine(smapiInternalDir, fileName);
if (File.Exists(targetFilePath))
{
File.Delete(targetFilePath);
}
File.Move(file, targetFilePath);
Console.WriteLine($"Moved file: {fileName} from arm64_v8a to smapi-internal.");
}
}
else
{
Console.WriteLine("The arm64_v8a directory does not exist or is empty.");
}
}
catch (Exception ex)
{
Console.WriteLine($"Error moving files from arm64_v8a to smapi-internal: {ex.Message}");
}
}
public static async Task MoveBuildingsFileToTargetDirectory(Android.Content.Context context)
{
try
{
string sourceDir = MainActivity.GetPrivateStoragePath();
string targetDir = Path.Combine(sourceDir, "Content", "Data");
string sourceFileName = "Buildings.xnb";
string targetFilePath = Path.Combine(targetDir, sourceFileName);
if (!Directory.Exists(targetDir))
{
Directory.CreateDirectory(targetDir);
}
AssetManager assets = context.Assets;
using (Stream assetStream = assets.Open(sourceFileName))
{
if (File.Exists(targetFilePath))
{
File.Delete(targetFilePath);
}
using (var fileStream = new FileStream(targetFilePath, FileMode.Create))
{
assetStream.CopyTo(fileStream);
}
Console.WriteLine("Buildings.xnb has been moved successfully from assets.");
MoveFilesFromArm64V8aToSmapiInternal(sourceDir);
}
}
catch (Exception ex)
{
Console.WriteLine($"Error moving Buildings.xnb from assets: {ex.Message}");
}
}
}