Exemplo n.º 1
0
        public int ReadFrom(byte[] buffer, int offset)
        {
            Header = Utilities.ToStruct <ExtentHeader>(buffer, offset + 0);
            if (Header.Magic != ExtentHeader.HeaderMagic)
            {
                throw new IOException("Invalid extent header reading inode");
            }

            if (Header.Depth == 0)
            {
                Index   = null;
                Extents = new Extent[Header.Entries];
                for (int i = 0; i < Extents.Length; ++i)
                {
                    Extents[i] = Utilities.ToStruct <Extent>(buffer, offset + 12 + i * 12);
                }
            }
            else
            {
                Extents = null;
                Index   = new ExtentIndex[Header.Entries];
                for (int i = 0; i < Index.Length; ++i)
                {
                    Index[i] = Utilities.ToStruct <ExtentIndex>(buffer, offset + 12 + i * 12);
                }
            }

            return(12 + Header.MaxEntries * 12);
        }
Exemplo n.º 2
0
        public int ReadFrom(byte[] buffer, int offset)
        {
            Header = Utilities.ToStruct<ExtentHeader>(buffer, offset + 0);
            if (Header.Magic != ExtentHeader.HeaderMagic)
            {
                throw new IOException("Invalid extent header reading inode");
            }

            if (Header.Depth == 0)
            {
                Index = null;
                Extents = new Extent[Header.Entries];
                for (int i = 0; i < Extents.Length; ++i)
                {
                    Extents[i] = Utilities.ToStruct<Extent>(buffer, offset + 12 + (i * 12));
                }
            }
            else
            {
                Extents = null;
                Index = new ExtentIndex[Header.Entries];
                for (int i = 0; i < Index.Length; ++i)
                {
                    Index[i] = Utilities.ToStruct<ExtentIndex>(buffer, offset + 12 + (i * 12));
                }
            }

            return 12 + (Header.MaxEntries * 12);
        }