mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-12-16 16:37:03 +00:00
parent
417df486b1
commit
361d0c5632
622 changed files with 3080 additions and 2652 deletions
|
|
@ -111,10 +111,12 @@ namespace Ryujinx.HLE.FileSystem
|
|||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!ContentPath.TryGetRealPath(contentPathString, out string contentDirectory))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string registeredDirectory = Path.Combine(contentDirectory, "registered");
|
||||
|
||||
Directory.CreateDirectory(registeredDirectory);
|
||||
|
|
@ -464,6 +466,7 @@ namespace Ryujinx.HLE.FileSystem
|
|||
{
|
||||
InstallFromZip(archive, temporaryDirectory);
|
||||
}
|
||||
|
||||
break;
|
||||
case ".xci":
|
||||
Xci xci = new(_virtualFileSystem.KeySet, file.AsStorage());
|
||||
|
|
@ -476,7 +479,7 @@ namespace Ryujinx.HLE.FileSystem
|
|||
FinishInstallation(temporaryDirectory, registeredDirectory);
|
||||
}
|
||||
|
||||
public void InstallKeys(string keysSource, string installDirectory)
|
||||
public static void InstallKeys(string keysSource, string installDirectory)
|
||||
{
|
||||
if (Directory.Exists(keysSource))
|
||||
{
|
||||
|
|
@ -505,6 +508,7 @@ namespace Ryujinx.HLE.FileSystem
|
|||
{
|
||||
InstallKeysFromZip(archive, installDirectory);
|
||||
}
|
||||
|
||||
break;
|
||||
case ".keys":
|
||||
VerifyKeysFile(keysSource);
|
||||
|
|
@ -515,13 +519,14 @@ namespace Ryujinx.HLE.FileSystem
|
|||
}
|
||||
}
|
||||
|
||||
private void InstallKeysFromZip(ZipArchive archive, string installDirectory)
|
||||
private static void InstallKeysFromZip(ZipArchive archive, string installDirectory)
|
||||
{
|
||||
string temporaryDirectory = Path.Combine(installDirectory, "temp");
|
||||
if (Directory.Exists(temporaryDirectory))
|
||||
{
|
||||
Directory.Delete(temporaryDirectory, true);
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(temporaryDirectory);
|
||||
foreach (ZipArchiveEntry entry in archive.Entries)
|
||||
{
|
||||
|
|
@ -541,6 +546,7 @@ namespace Ryujinx.HLE.FileSystem
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Directory.Delete(temporaryDirectory, true);
|
||||
}
|
||||
|
||||
|
|
@ -567,7 +573,7 @@ namespace Ryujinx.HLE.FileSystem
|
|||
{
|
||||
Nca nca = new(_virtualFileSystem.KeySet, OpenPossibleFragmentedFile(filesystem, entry.FullPath, OpenMode.Read).AsStorage());
|
||||
|
||||
SaveNca(nca, entry.Name.Remove(entry.Name.IndexOf('.')), temporaryDirectory);
|
||||
SaveNca(nca, entry.Name[..entry.Name.IndexOf('.')], temporaryDirectory);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -641,7 +647,7 @@ namespace Ryujinx.HLE.FileSystem
|
|||
return file.Release();
|
||||
}
|
||||
|
||||
private static Stream GetZipStream(ZipArchiveEntry entry)
|
||||
private static MemoryStream GetZipStream(ZipArchiveEntry entry)
|
||||
{
|
||||
MemoryStream dest = MemoryStreamManager.Shared.GetStream();
|
||||
|
||||
|
|
@ -1016,7 +1022,7 @@ namespace Ryujinx.HLE.FileSystem
|
|||
return null;
|
||||
}
|
||||
|
||||
public void VerifyKeysFile(string filePath)
|
||||
public static void VerifyKeysFile(string filePath)
|
||||
{
|
||||
// Verify the keys file format refers to https://github.com/Thealexbarney/LibHac/blob/master/KEYS.md
|
||||
string genericPattern = @"^[a-z0-9_]+ = [a-z0-9]+$";
|
||||
|
|
@ -1028,7 +1034,7 @@ namespace Ryujinx.HLE.FileSystem
|
|||
string fileName = Path.GetFileName(filePath);
|
||||
string[] lines = File.ReadAllLines(filePath);
|
||||
|
||||
bool verified = false;
|
||||
bool verified;
|
||||
switch (fileName)
|
||||
{
|
||||
case "prod.keys":
|
||||
|
|
@ -1046,18 +1052,20 @@ namespace Ryujinx.HLE.FileSystem
|
|||
default:
|
||||
throw new FormatException($"Keys file name \"{fileName}\" not supported. Only \"prod.keys\", \"title.keys\", \"console.keys\", \"dev.keys\" are supported.");
|
||||
}
|
||||
|
||||
if (!verified)
|
||||
{
|
||||
throw new FormatException($"Invalid \"{filePath}\" file format.");
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new FileNotFoundException($"Keys file not found at \"{filePath}\".");
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
bool VerifyKeys(string[] lines, string regex)
|
||||
|
||||
static bool VerifyKeys(string[] lines, string regex)
|
||||
{
|
||||
foreach (string line in lines)
|
||||
{
|
||||
|
|
@ -1066,11 +1074,12 @@ namespace Ryujinx.HLE.FileSystem
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool AreKeysAlredyPresent(string pathToCheck)
|
||||
|
||||
public static bool AreKeysAlredyPresent(string pathToCheck)
|
||||
{
|
||||
string[] fileNames = ["prod.keys", "title.keys", "console.keys", "dev.keys"];
|
||||
foreach (string file in fileNames)
|
||||
|
|
@ -1080,6 +1089,7 @@ namespace Ryujinx.HLE.FileSystem
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue