|
|
@@ -141,20 +141,8 @@ namespace Ryujinx.Ava.Common
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static async Task ExtractSection(IStorageProvider storageProvider, NcaSectionType ncaSectionType, string titleFilePath, string titleName, int programIndex = 0)
|
|
|
+ public static void ExtractSection(string destination, NcaSectionType ncaSectionType, string titleFilePath, string titleName, int programIndex = 0)
|
|
|
{
|
|
|
- var result = await storageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
|
|
- {
|
|
|
- Title = LocaleManager.Instance[LocaleKeys.FolderDialogExtractTitle],
|
|
|
- AllowMultiple = false,
|
|
|
- });
|
|
|
-
|
|
|
- if (result.Count == 0)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- var destination = result[0].Path.LocalPath;
|
|
|
var cancellationToken = new CancellationTokenSource();
|
|
|
|
|
|
UpdateWaitWindow waitingDialog = new(
|
|
|
@@ -172,11 +160,11 @@ namespace Ryujinx.Ava.Common
|
|
|
Nca patchNca = null;
|
|
|
|
|
|
string extension = Path.GetExtension(titleFilePath).ToLower();
|
|
|
- if (extension == ".nsp" || extension == ".pfs0" || extension == ".xci")
|
|
|
+ if (extension is ".nsp" or ".pfs0" or ".xci")
|
|
|
{
|
|
|
IFileSystem pfs;
|
|
|
|
|
|
- if (extension == ".xci")
|
|
|
+ if (extension is ".xci")
|
|
|
{
|
|
|
pfs = new Xci(_virtualFileSystem.KeySet, file.AsStorage()).OpenPartition(XciPartitionType.Secure);
|
|
|
}
|
|
|
@@ -194,7 +182,7 @@ namespace Ryujinx.Ava.Common
|
|
|
pfs.OpenFile(ref ncaFile.Ref, fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
|
|
|
|
|
Nca nca = new(_virtualFileSystem.KeySet, ncaFile.Get.AsStorage());
|
|
|
- if (nca.Header.ContentType == NcaContentType.Program)
|
|
|
+ if (nca.Header.ContentType is NcaContentType.Program)
|
|
|
{
|
|
|
int dataIndex = Nca.GetSectionIndexFromType(NcaSectionType.Data, NcaContentType.Program);
|
|
|
if (nca.SectionExists(NcaSectionType.Data) && nca.Header.GetFsHeader(dataIndex).IsPatchSection())
|
|
|
@@ -208,12 +196,12 @@ namespace Ryujinx.Ava.Common
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else if (extension == ".nca")
|
|
|
+ else if (extension is ".nca")
|
|
|
{
|
|
|
mainNca = new Nca(_virtualFileSystem.KeySet, file.AsStorage());
|
|
|
}
|
|
|
|
|
|
- if (mainNca == null)
|
|
|
+ if (mainNca is null)
|
|
|
{
|
|
|
Logger.Error?.Print(LogClass.Application, "Extraction failure. The main NCA was not present in the selected file");
|
|
|
|
|
|
@@ -232,7 +220,7 @@ namespace Ryujinx.Ava.Common
|
|
|
: IntegrityCheckLevel.None;
|
|
|
|
|
|
(Nca updatePatchNca, _) = mainNca.GetUpdateData(_virtualFileSystem, checkLevel, programIndex, out _);
|
|
|
- if (updatePatchNca != null)
|
|
|
+ if (updatePatchNca is not null)
|
|
|
{
|
|
|
patchNca = updatePatchNca;
|
|
|
}
|
|
|
@@ -242,7 +230,7 @@ namespace Ryujinx.Ava.Common
|
|
|
try
|
|
|
{
|
|
|
bool sectionExistsInPatch = false;
|
|
|
- if (patchNca != null)
|
|
|
+ if (patchNca is not null)
|
|
|
{
|
|
|
sectionExistsInPatch = patchNca.CanOpenSection(index);
|
|
|
}
|
|
|
@@ -309,6 +297,23 @@ namespace Ryujinx.Ava.Common
|
|
|
extractorThread.Start();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public static async Task ExtractSection(IStorageProvider storageProvider, NcaSectionType ncaSectionType, string titleFilePath, string titleName, int programIndex = 0)
|
|
|
+ {
|
|
|
+ var result = await storageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
|
|
+ {
|
|
|
+ Title = LocaleManager.Instance[LocaleKeys.FolderDialogExtractTitle],
|
|
|
+ AllowMultiple = false,
|
|
|
+ });
|
|
|
+
|
|
|
+ if (result.Count == 0)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ ExtractSection(result[0].Path.LocalPath, ncaSectionType, titleFilePath, titleName, programIndex);
|
|
|
+ }
|
|
|
+
|
|
|
public static (Result? result, bool canceled) CopyDirectory(FileSystemClient fs, string sourcePath, string destPath, CancellationToken token)
|
|
|
{
|
|
|
Result rc = fs.OpenDirectory(out DirectoryHandle sourceHandle, sourcePath.ToU8Span(), OpenDirectoryMode.All);
|