public XciPartitionItem(XciPartition xciPartition, XciPartitionType xciPartitionType, XciItem parentItem) : base(xciPartition) { XciPartition = xciPartition ?? throw new ArgumentNullException(nameof(xciPartition)); XciPartitionType = xciPartitionType; ParentItem = parentItem ?? throw new ArgumentNullException(nameof(parentItem)); }
public bool HasPartition(XciPartitionType type) { if (type == XciPartitionType.Root) { return(true); } return(GetRootPartition().FileExists(type.GetFileName())); }
public XciPartition OpenPartition(XciPartitionType type) { XciPartition root = GetRootPartition(); if (type == XciPartitionType.Root) { return(root); } root.OpenFile(out IFile partitionFile, type.GetFileName().ToU8Span(), OpenMode.Read).ThrowIfFailure(); return(new XciPartition(partitionFile.AsStorage())); }
public XciPartition OpenPartition(XciPartitionType type) { XciPartition root = GetRootPartition(); if (type == XciPartitionType.Root) { return(root); } IStorage partitionStorage = root.OpenFile(type.GetFileName(), OpenMode.Read).AsStorage(); return(new XciPartition(partitionStorage)); }
public static string GetFileName(this XciPartitionType type) { switch (type) { case XciPartitionType.Update: return("update"); case XciPartitionType.Normal: return("normal"); case XciPartitionType.Secure: return("secure"); case XciPartitionType.Logo: return("logo"); case XciPartitionType.Root: return("root"); default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } }
private static void PrintPartition(StringBuilder sb, int colLen, XciPartition partition, XciPartitionType type) { const int fileNameLen = 57; sb.AppendLine($"{type.ToString()} Partition:{partition.HashValidity.GetValidityString()}"); PrintItem(sb, colLen, " Magic:", partition.Header.Magic); PrintItem(sb, colLen, " Offset:", $"{partition.Offset:x12}"); PrintItem(sb, colLen, " Number of files:", partition.Files.Length); string name = type.GetFileName(); if (partition.Files.Length > 0 && partition.Files.Length < 100) { for (int i = 0; i < partition.Files.Length; i++) { PartitionFileEntry file = partition.Files[i]; string label = i == 0 ? " Files:" : ""; string offsets = $"{file.Offset:x12}-{file.Offset + file.Size:x12}{file.HashValidity.GetValidityString()}"; string data = $"{name}:/{file.Name}".PadRight(fileNameLen) + offsets; PrintItem(sb, colLen, label, data); } } }