aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.HLE/Loaders/Processes/Extensions/LocalFileSystemExtensions.cs
blob: 6c2a19894b2d6ca8ef1ecf3fcb96baa0a2ade630 (plain) (blame)
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
using LibHac.Common;
using LibHac.FsSystem;
using LibHac.Loader;
using LibHac.Ncm;
using LibHac.Ns;
using Ryujinx.HLE.Loaders.Processes.Extensions;

namespace Ryujinx.HLE.Loaders.Processes
{
    static class LocalFileSystemExtensions
    {
        public static ProcessResult Load(this LocalFileSystem exeFs, Switch device, string romFsPath = "")
        {
            MetaLoader metaLoader = exeFs.GetNpdm();
            var nacpData = new BlitStruct<ApplicationControlProperty>(1);
            ulong programId = metaLoader.GetProgramId();

            device.Configuration.VirtualFileSystem.ModLoader.CollectMods(new[] { programId });

            if (programId != 0)
            {
                ProcessLoaderHelper.EnsureSaveData(device, new ApplicationId(programId), nacpData);
            }

            ProcessResult processResult = exeFs.Load(device, nacpData, metaLoader, 0);

            // Load RomFS.
            if (!string.IsNullOrEmpty(romFsPath))
            {
                device.Configuration.VirtualFileSystem.LoadRomFs(processResult.ProcessId, romFsPath);
            }

            return processResult;
        }
    }
}