private BaseItem CreateItem(NodeItem item, byte[] buffer, int offset) { var data = EndianUtilities.ToByteArray(buffer, (int)(offset + item.DataOffset), (int)item.DataSize); BaseItem result; switch (item.Key.ItemType) { case ItemType.ChunkItem: result = new ChunkItem(item.Key); break; case ItemType.DevItem: result = new DevItem(item.Key); break; case ItemType.RootItem: result = new RootItem(item.Key); break; case ItemType.InodeRef: result = new InodeRef(item.Key); break; case ItemType.InodeItem: result = new InodeItem(item.Key); break; case ItemType.DirItem: result = new DirItem(item.Key); break; case ItemType.DirIndex: result = new DirIndex(item.Key); break; case ItemType.ExtentData: result = new ExtentData(item.Key); break; case ItemType.RootRef: result = new RootRef(item.Key); break; case ItemType.RootBackref: result = new RootBackref(item.Key); break; case ItemType.XattrItem: result = new XattrItem(item.Key); break; case ItemType.OrphanItem: result = new OrphanItem(item.Key); break; default: throw new IOException($"Unsupported item type {item.Key.ItemType}"); } result.ReadFrom(data, 0); return(result); }
public DirEntry(ulong treeId, DirIndex item, InodeItem inode) : this(treeId, item.ChildLocation.ObjectId) { _inode = inode; _item = item; }