public void ReadFrom_Works() { byte[] data = Convert.FromBase64String("AAMAAAAAAAEABQBYAGMAbwBkAGU="); CatalogThread thread = new CatalogThread(); Assert.Equal(20, thread.ReadFrom(data, 0)); Assert.Equal("Xcode", thread.Name); Assert.Equal(new CatalogNodeId(1), thread.ParentId); Assert.Equal(CatalogRecordType.FolderThreadRecord, thread.RecordType); Assert.Equal(20, thread.Size); }
private Node(byte[] bytes, string volumeName, string fileName, uint nodeNumber) { VolumeName = volumeName; FileName = fileName; NodeNumber = nodeNumber; NodeDescriptor = NodeDescriptor.Get(bytes, 0x00, volumeName, fileName); List <Record> recordList = new List <Record>(); switch (NodeDescriptor.Kind) { case NodeDescriptor.NODE_KIND.kBTHeaderNode: recordList.Add(HeaderRecord.Get(bytes, Helper.SwapEndianness(BitConverter.ToUInt16(bytes, bytes.Length - 0x02)), volumeName, fileName)); recordList.Add(UserDataRecord.Get(bytes, Helper.SwapEndianness(BitConverter.ToUInt16(bytes, bytes.Length - 0x04)))); //recordList.Add(Helper.GetSubArray(bytes, Helper.SwapEndianness(BitConverter.ToUInt16(bytes, bytes.Length - 0x06)), )); break; case NodeDescriptor.NODE_KIND.kBTIndexNode: for (int i = 1; i <= NodeDescriptor.NumRecords; i++) { ushort recordOffset = Helper.SwapEndianness(BitConverter.ToUInt16(bytes, bytes.Length - (0x02 * i))); recordList.Add(PointerRecord.Get(bytes, recordOffset, volumeName, fileName)); } break; case NodeDescriptor.NODE_KIND.kBTLeafNode: for (int i = 1; i <= NodeDescriptor.NumRecords; i++) { ushort recordOffset = Helper.SwapEndianness(BitConverter.ToUInt16(bytes, bytes.Length - (0x02 * i))); switch (fileName) { case "Catalog": switch (DataRecord.GetRecordType(bytes, recordOffset)) { case DataRecord.RECORD_TYPE.kHFSPlusFolderRecord: recordList.Add(CatalogFolderRecord.Get(bytes, recordOffset, volumeName, fileName)); break; case DataRecord.RECORD_TYPE.kHFSPlusFileRecord: recordList.Add(CatalogFileRecord.Get(bytes, recordOffset, volumeName, fileName)); break; case DataRecord.RECORD_TYPE.kHFSPlusFolderThreadRecord: recordList.Add(CatalogThread.Get(bytes, recordOffset, volumeName, fileName)); break; case DataRecord.RECORD_TYPE.kHFSPlusFileThreadRecord: recordList.Add(CatalogThread.Get(bytes, recordOffset, volumeName, fileName)); break; } break; case "ExtentsOverflow": recordList.Add(ExtentsOverflowRecord.Get(bytes, recordOffset, volumeName, fileName)); break; } } break; case NodeDescriptor.NODE_KIND.kBTMapNode: break; } Records = recordList.ToArray(); }
public void WriteTo_Throws() { var thread = new CatalogThread(); Assert.Throws <NotImplementedException>(() => thread.WriteTo(Array.Empty <byte>(), 0)); }