Skip to content

Commit

Permalink
Use external data location for readonly file systems
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchLeaders committed Feb 26, 2025
1 parent c80ba47 commit b6d6ed9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ jobs:
--version-suffix ${{ needs.release.outputs.version }} \
-p:Version=${{ needs.release.outputs.version }} \
-p:NoUpdate=true \
-p:DebugType=embedded
-p:DebugType=embedded \
-p:IsReadonlyFileSystem=True
- name: Build AppImage
shell: bash
Expand Down
1 change: 1 addition & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<PropertyGroup>
<DefineConstants Condition="'$(NoUpdate)' == 'true'">$(DefineConstants);NO_UPDATE</DefineConstants>
<DefineConstants Condition="'$(IsSwitch)' == 'true'">$(DefineConstants);SWITCH;TARGET_NX</DefineConstants>
<DefineConstants Condition="'$(IsReadonlyFileSystem)' == 'true'">$(DefineConstants);READONLY_FS</DefineConstants>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Tkmm.Core/Logging/DesktopLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Tkmm.Core.Logging;

public class DesktopLogger : ILogger
{
private static readonly string _logsFolder = Path.Combine(AppContext.BaseDirectory, "Logs");
private static readonly string _logsFolder = Path.Combine(TKMM.BaseDirectory, "Logs");
private static readonly string _targetLogFile = Path.Combine(_logsFolder, $"{DateTime.UtcNow:yy-MM-dd-HH-mm-ss}.log");

private readonly string _group;
Expand Down
13 changes: 10 additions & 3 deletions src/Tkmm.Core/TKMM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ namespace Tkmm.Core;
// ReSharper disable once InconsistentNaming
public static class TKMM
{
#if READONLY_FS
public static readonly string BaseDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "tkmm2");
#else
public static readonly string BaseDirectory = AppContext.BaseDirectory;
#endif

private static readonly TkModReaderProvider _readerProvider;
private static ITkThumbnailProvider? _thumbnailProvider;

Expand All @@ -30,7 +36,7 @@ public static class TKMM
#if SWITCH
public static readonly string MergedOutputFolder = "/flash/atmosphere/contents/0100F2C0115B6000";
#else
public static string MergedOutputFolder => Config.Shared.MergeOutput ?? Path.Combine(AppContext.BaseDirectory, "Merged");
public static string MergedOutputFolder => Config.Shared.MergeOutput ?? Path.Combine(BaseDirectory, "Merged");
#endif

public static ITkRom GetTkRom() => RomProvider.GetRom();
Expand Down Expand Up @@ -138,7 +144,8 @@ public static void MergeBasic(TkProfile? profile = null, CancellationToken ct =

static TKMM()
{
ModManager = TkModManager.CreatePortable();
string dataFolder = Path.Combine(BaseDirectory, ".data");
ModManager = TkModManager.Create(dataFolder);
ModManager.CurrentProfile = ModManager.GetCurrentProfile();

ModManager.PropertyChanged += static (s, e) => {
Expand All @@ -153,7 +160,7 @@ static TKMM()
_readerProvider.Register(new External7zModReader(ModManager, RomProvider));

Span<string> hiddenSystemFolders = [".data", ".layout"];
DirectoryHelper.HideTargetsInDirectory(AppContext.BaseDirectory, hiddenSystemFolders);
DirectoryHelper.HideTargetsInDirectory(TKMM.BaseDirectory, hiddenSystemFolders);

if (Environment.ProcessPath is null) {
return;
Expand Down

0 comments on commit b6d6ed9

Please sign in to comment.