mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Package2 opening and various tweaks (#35)
* Add package2 opening to LibHac.Nand * Add utility methods for enumerating FileSystems
This commit is contained in:
parent
632d508e40
commit
41b9f3088e
4 changed files with 36 additions and 6 deletions
|
@ -45,7 +45,7 @@ namespace LibHac.Nand
|
||||||
{
|
{
|
||||||
path = ToDiscUtilsPath(PathTools.Normalize(path));
|
path = ToDiscUtilsPath(PathTools.Normalize(path));
|
||||||
|
|
||||||
if (path == @"\\") return true;
|
if (path == @"\") return true;
|
||||||
|
|
||||||
return Fs.DirectoryExists(path);
|
return Fs.DirectoryExists(path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ namespace LibHac.Nand
|
||||||
{
|
{
|
||||||
private GuidPartitionInfo ProdInfo { get; }
|
private GuidPartitionInfo ProdInfo { get; }
|
||||||
private GuidPartitionInfo ProdInfoF { get; }
|
private GuidPartitionInfo ProdInfoF { get; }
|
||||||
|
private GuidPartitionInfo[] Package2 { get; }
|
||||||
private GuidPartitionInfo Safe { get; }
|
private GuidPartitionInfo Safe { get; }
|
||||||
private GuidPartitionInfo System { get; }
|
private GuidPartitionInfo System { get; }
|
||||||
private GuidPartitionInfo User { get; }
|
private GuidPartitionInfo User { get; }
|
||||||
|
@ -23,6 +24,15 @@ namespace LibHac.Nand
|
||||||
GuidPartitionInfo[] partitions = disc.Partitions.Select(x => (GuidPartitionInfo)x).ToArray();
|
GuidPartitionInfo[] partitions = disc.Partitions.Select(x => (GuidPartitionInfo)x).ToArray();
|
||||||
ProdInfo = partitions.FirstOrDefault(x => x.Name == "PRODINFO");
|
ProdInfo = partitions.FirstOrDefault(x => x.Name == "PRODINFO");
|
||||||
ProdInfoF = partitions.FirstOrDefault(x => x.Name == "PRODINFOF");
|
ProdInfoF = partitions.FirstOrDefault(x => x.Name == "PRODINFOF");
|
||||||
|
Package2 = new GuidPartitionInfo[]
|
||||||
|
{
|
||||||
|
partitions.FirstOrDefault(x => x.Name == "BCPKG2-1-Normal-Main"),
|
||||||
|
partitions.FirstOrDefault(x => x.Name == "BCPKG2-2-Normal-Sub"),
|
||||||
|
partitions.FirstOrDefault(x => x.Name == "BCPKG2-3-SafeMode-Main"),
|
||||||
|
partitions.FirstOrDefault(x => x.Name == "BCPKG2-4-SafeMode-Sub"),
|
||||||
|
partitions.FirstOrDefault(x => x.Name == "BCPKG2-5-Repair-Main"),
|
||||||
|
partitions.FirstOrDefault(x => x.Name == "BCPKG2-6-Repair-Sub")
|
||||||
|
};
|
||||||
Safe = partitions.FirstOrDefault(x => x.Name == "SAFE");
|
Safe = partitions.FirstOrDefault(x => x.Name == "SAFE");
|
||||||
System = partitions.FirstOrDefault(x => x.Name == "SYSTEM");
|
System = partitions.FirstOrDefault(x => x.Name == "SYSTEM");
|
||||||
User = partitions.FirstOrDefault(x => x.Name == "USER");
|
User = partitions.FirstOrDefault(x => x.Name == "USER");
|
||||||
|
@ -44,6 +54,11 @@ namespace LibHac.Nand
|
||||||
return new FatFileSystemProvider(fat);
|
return new FatFileSystemProvider(fat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IStorage OpenPackage2(int index)
|
||||||
|
{
|
||||||
|
return Package2[index].Open().AsStorage().AsReadOnly();
|
||||||
|
}
|
||||||
|
|
||||||
public FatFileSystemProvider OpenSafePartition()
|
public FatFileSystemProvider OpenSafePartition()
|
||||||
{
|
{
|
||||||
IStorage encStorage = Safe.Open().AsStorage();
|
IStorage encStorage = Safe.Open().AsStorage();
|
||||||
|
|
|
@ -61,7 +61,17 @@ namespace LibHac.IO
|
||||||
|
|
||||||
public static IEnumerable<DirectoryEntry> EnumerateEntries(this IFileSystem fileSystem)
|
public static IEnumerable<DirectoryEntry> EnumerateEntries(this IFileSystem fileSystem)
|
||||||
{
|
{
|
||||||
return fileSystem.OpenDirectory("/", OpenDirectoryMode.All).EnumerateEntries("*", SearchOptions.RecurseSubdirectories);
|
return fileSystem.EnumerateEntries("*");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IEnumerable<DirectoryEntry> EnumerateEntries(this IFileSystem fileSystem, string searchPattern)
|
||||||
|
{
|
||||||
|
return fileSystem.EnumerateEntries(searchPattern, SearchOptions.RecurseSubdirectories);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IEnumerable<DirectoryEntry> EnumerateEntries(this IFileSystem fileSystem, string searchPattern, SearchOptions searchOptions)
|
||||||
|
{
|
||||||
|
return fileSystem.OpenDirectory("/", OpenDirectoryMode.All).EnumerateEntries(searchPattern, searchOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<DirectoryEntry> EnumerateEntries(this IDirectory directory)
|
public static IEnumerable<DirectoryEntry> EnumerateEntries(this IDirectory directory)
|
||||||
|
|
|
@ -343,14 +343,19 @@ namespace LibHac
|
||||||
AllKeyDict = uniqueKeys.Concat(commonKeys).ToDictionary(k => k.Name, k => k);
|
AllKeyDict = uniqueKeys.Concat(commonKeys).ToDictionary(k => k.Name, k => k);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Keyset ReadKeyFile(string filename, string titleKeysFilename = null, string consoleKeysFilename = null, IProgressReport logger = null)
|
public static void ReadKeyFile(Keyset keyset, string filename, string titleKeysFilename = null, string consoleKeysFilename = null, IProgressReport logger = null)
|
||||||
{
|
{
|
||||||
var keyset = new Keyset();
|
|
||||||
|
|
||||||
if (filename != null) ReadMainKeys(keyset, filename, AllKeyDict, logger);
|
if (filename != null) ReadMainKeys(keyset, filename, AllKeyDict, logger);
|
||||||
if (consoleKeysFilename != null) ReadMainKeys(keyset, consoleKeysFilename, AllKeyDict, logger);
|
if (consoleKeysFilename != null) ReadMainKeys(keyset, consoleKeysFilename, AllKeyDict, logger);
|
||||||
if (titleKeysFilename != null) ReadTitleKeys(keyset, titleKeysFilename, logger);
|
if (titleKeysFilename != null) ReadTitleKeys(keyset, titleKeysFilename, logger);
|
||||||
keyset.DeriveKeys(logger);
|
keyset.DeriveKeys(logger);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Keyset ReadKeyFile(string filename, string titleKeysFilename = null, string consoleKeysFilename = null, IProgressReport logger = null)
|
||||||
|
{
|
||||||
|
var keyset = new Keyset();
|
||||||
|
|
||||||
|
ReadKeyFile(keyset, filename, titleKeysFilename, consoleKeysFilename, logger);
|
||||||
|
|
||||||
return keyset;
|
return keyset;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue