AcK's requested changes

This commit is contained in:
Xpl0itR 2020-01-24 19:02:10 +00:00
commit 4a6ae533dd
No known key found for this signature in database
GPG key ID: 91798184109676AD
3 changed files with 28 additions and 9 deletions

View file

@ -48,6 +48,14 @@ namespace Ryujinx.Ui
_gameTableStore = gameTableStore; _gameTableStore = gameTableStore;
_rowIter = rowIter; _rowIter = rowIter;
_virtualFileSystem = virtualFileSystem; _virtualFileSystem = virtualFileSystem;
string ext = System.IO.Path.GetExtension(_gameTableStore.GetValue(_rowIter, 9).ToString()).ToLower();
if (ext != ".nca" && ext != ".nsp" && ext != ".pfs0" && ext != ".xci")
{
_extractRomFs.Sensitive = false;
_extractExeFs.Sensitive = false;
_extractLogo.Sensitive = false;
}
} }
private bool TryFindSaveData(string titleName, string titleIdText, out ulong saveDataId) private bool TryFindSaveData(string titleName, string titleIdText, out ulong saveDataId)
@ -197,8 +205,10 @@ namespace Ryujinx.Ui
if (mainNca == null) if (mainNca == null)
{ {
Logger.PrintError(LogClass.Application, "Extraction failed. The main NCA was not present in the selected file."); Logger.PrintError(LogClass.Application, "Extraction failed. The main NCA was not present in the selected file.");
GtkDialog.CreateErrorDialog("Extraction failed. The main NCA was not present in the selected file.");
fileChooser.Dispose(); fileChooser.Dispose();
return; return;
} }
@ -217,7 +227,12 @@ namespace Ryujinx.Ui
_virtualFileSystem.FsClient.Register(ncaSectionType.ToString().ToU8Span(), ncaFileSystem); _virtualFileSystem.FsClient.Register(ncaSectionType.ToString().ToU8Span(), ncaFileSystem);
_virtualFileSystem.FsClient.Register("output".ToU8Span(), new LocalFileSystem(fileChooser.Filename)); _virtualFileSystem.FsClient.Register("output".ToU8Span(), new LocalFileSystem(fileChooser.Filename));
CopyDirectory(_virtualFileSystem.FsClient, $"{ncaSectionType}:/", "output:/"); Result rc = CopyDirectory(_virtualFileSystem.FsClient, $"{ncaSectionType}:/", "output:/");
if (rc.IsFailure())
{
Logger.PrintError(LogClass.Application, $"LibHac returned error code: {rc.ErrorCode}");
GtkDialog.CreateErrorDialog($"Extraction failed. Read the log file for further information.");
}
_virtualFileSystem.FsClient.Unmount(ncaSectionType.ToString()); _virtualFileSystem.FsClient.Unmount(ncaSectionType.ToString());
_virtualFileSystem.FsClient.Unmount("output"); _virtualFileSystem.FsClient.Unmount("output");
@ -227,9 +242,10 @@ namespace Ryujinx.Ui
fileChooser.Dispose(); fileChooser.Dispose();
} }
private static void CopyDirectory(FileSystemClient fs, string sourcePath, string destPath) private static Result CopyDirectory(FileSystemClient fs, string sourcePath, string destPath)
{ {
fs.OpenDirectory(out DirectoryHandle sourceHandle, sourcePath, OpenDirectoryMode.All).ThrowIfFailure(); Result rc = fs.OpenDirectory(out DirectoryHandle sourceHandle, sourcePath, OpenDirectoryMode.All);
if (rc.IsFailure()) return rc;
using (sourceHandle) using (sourceHandle)
{ {
@ -242,17 +258,21 @@ namespace Ryujinx.Ui
{ {
fs.EnsureDirectoryExists(subDstPath); fs.EnsureDirectoryExists(subDstPath);
CopyDirectory(fs, subSrcPath, subDstPath); rc = CopyDirectory(fs, subSrcPath, subDstPath);
if (rc.IsFailure()) return rc;
} }
if (entry.Type == DirectoryEntryType.File) if (entry.Type == DirectoryEntryType.File)
{ {
fs.CreateOrOverwriteFile(subDstPath, entry.Size); fs.CreateOrOverwriteFile(subDstPath, entry.Size);
CopyFile(fs, subSrcPath, subDstPath); rc = CopyFile(fs, subSrcPath, subDstPath);
if (rc.IsFailure()) return rc;
} }
} }
} }
return Result.Success;
} }
public static Result CopyFile(FileSystemClient fs, string sourcePath, string destPath) public static Result CopyFile(FileSystemClient fs, string sourcePath, string destPath)

View file

@ -24,7 +24,7 @@
<object class="GtkMenuItem" id="_extractRomFs"> <object class="GtkMenuItem" id="_extractRomFs">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label" translatable="yes">Extract RomFS</property> <property name="label" translatable="yes">Extract RomFS Section</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
</object> </object>
</child> </child>
@ -32,7 +32,7 @@
<object class="GtkMenuItem" id="_extractExeFs"> <object class="GtkMenuItem" id="_extractExeFs">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label" translatable="yes">Extract ExeFS</property> <property name="label" translatable="yes">Extract ExeFS Section</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
</object> </object>
</child> </child>
@ -40,7 +40,7 @@
<object class="GtkMenuItem" id="_extractLogo"> <object class="GtkMenuItem" id="_extractLogo">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label" translatable="yes">Extract Logo</property> <property name="label" translatable="yes">Extract Logo Section</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
</object> </object>
</child> </child>

View file

@ -547,7 +547,6 @@ namespace Ryujinx.Ui
if (treeIter.UserData == IntPtr.Zero) return; if (treeIter.UserData == IntPtr.Zero) return;
GameTableContextMenu contextMenu = new GameTableContextMenu(_tableStore, treeIter, _virtualFileSystem); GameTableContextMenu contextMenu = new GameTableContextMenu(_tableStore, treeIter, _virtualFileSystem);
contextMenu.ShowAll(); contextMenu.ShowAll();
contextMenu.PopupAtPointer(null); contextMenu.PopupAtPointer(null);
} }