Exemplo n.º 1
0
        private void getRecords()
        {
            forkDataRecords = new List <HFSPlusAttrForkData>();
            extentsRecords  = new List <HFSPlusAttrExtents>();
            inlineRecords   = new List <HFSPlusAttrInlineData>();

            foreach (rawKeyAndRecord raw in this.rawRecords)
            {
                type recordType = (type)dataOperations.convToLE(BitConverter.ToUInt32(raw.recordData, 0));

                switch (recordType)
                {
                case type.kHFSPlusAttrExtents:
                    HFSPlusAttrExtents exrecord = new HFSPlusAttrExtents();

                    exrecord.key        = attributesFile.buildAttrTrialKey(raw);
                    exrecord.recordType = type.kHFSPlusAttrExtents;
                    exrecord.reserved   = dataOperations.convToLE(BitConverter.ToUInt32(raw.recordData, 4));

                    byte[] extentsData = new byte[raw.recordData.Length - 8];
                    Array.Copy(raw.recordData, 8, extentsData, 0, raw.recordData.Length - 8);
                    exrecord.extents = new hfsPlusForkData.HFSPlusExtentRecord[extentsData.Length / 8];

                    for (int i = 0; i < extentsData.Length / 8; i++)
                    {
                        exrecord.extents[i].startBlock = dataOperations.convToLE(BitConverter.ToUInt32(extentsData, i * 8));
                        exrecord.extents[i].blockCount = dataOperations.convToLE(BitConverter.ToUInt32(extentsData, (i * 8) + 4));
                    }

                    extentsRecords.Add(exrecord);
                    break;

                case type.kHFSPlusAttrForkData:
                    HFSPlusAttrForkData fdrecord = new HFSPlusAttrForkData();

                    fdrecord.key        = attributesFile.buildAttrTrialKey(raw);
                    fdrecord.recordType = type.kHFSPlusAttrForkData;
                    fdrecord.reserved   = dataOperations.convToLE(BitConverter.ToUInt32(raw.recordData, 4));

                    byte[] fdrecordData = raw.recordData;

                    fdrecord.theFork = new hfsPlusForkData(ref fdrecordData, 8);

                    forkDataRecords.Add(fdrecord);

                    break;

                case type.kHFSPlusAttrInlineData:
                    HFSPlusAttrInlineData attrRecord = new HFSPlusAttrInlineData();

                    attrRecord.key        = attributesFile.buildAttrTrialKey(raw);
                    attrRecord.recordType = type.kHFSPlusAttrInlineData;
                    attrRecord.otherData  = new byte[raw.recordData.Length - 4];
                    Array.Copy(raw.recordData, 4, attrRecord.otherData, 0, attrRecord.otherData.Length);

                    inlineRecords.Add(attrRecord);
                    break;
                }
            }
        }
Exemplo n.º 2
0
        private void getRecords()
        {
            forkDataRecords = new List<HFSPlusAttrForkData>();
            extentsRecords = new List<HFSPlusAttrExtents>();
            inlineRecords = new List<HFSPlusAttrInlineData>();

            foreach (rawKeyAndRecord raw in this.rawRecords)
            {
                type recordType = (type)dataOperations.convToLE(BitConverter.ToUInt32(raw.recordData, 0));

                switch (recordType)
                {
                    case type.kHFSPlusAttrExtents:
                        HFSPlusAttrExtents exrecord = new HFSPlusAttrExtents();

                        exrecord.key = attributesFile.buildAttrTrialKey(raw);
                        exrecord.recordType = type.kHFSPlusAttrExtents;
                        exrecord.reserved = dataOperations.convToLE(BitConverter.ToUInt32(raw.recordData, 4));

                        byte[] extentsData = new byte[raw.recordData.Length - 8];
                        Array.Copy(raw.recordData, 8, extentsData, 0, raw.recordData.Length - 8);
                        exrecord.extents = new hfsPlusForkData.HFSPlusExtentRecord[extentsData.Length / 8];

                        for (int i = 0; i < extentsData.Length / 8; i++)
                        {
                            exrecord.extents[i].startBlock = dataOperations.convToLE(BitConverter.ToUInt32(extentsData, i * 8));
                            exrecord.extents[i].blockCount = dataOperations.convToLE(BitConverter.ToUInt32(extentsData, (i * 8) + 4));
                        }

                        extentsRecords.Add(exrecord);
                        break;
                    case type.kHFSPlusAttrForkData:
                        HFSPlusAttrForkData fdrecord = new HFSPlusAttrForkData();

                        fdrecord.key = attributesFile.buildAttrTrialKey(raw);
                        fdrecord.recordType = type.kHFSPlusAttrForkData;
                        fdrecord.reserved = dataOperations.convToLE(BitConverter.ToUInt32(raw.recordData, 4));

                        byte[] fdrecordData = raw.recordData;

                        fdrecord.theFork = new hfsPlusForkData(ref fdrecordData, 8);

                        forkDataRecords.Add(fdrecord);

                        break;
                    case type.kHFSPlusAttrInlineData:
                        HFSPlusAttrInlineData attrRecord = new HFSPlusAttrInlineData();

                        attrRecord.key = attributesFile.buildAttrTrialKey(raw);
                        attrRecord.recordType = type.kHFSPlusAttrInlineData;
                        attrRecord.otherData = new byte[raw.recordData.Length - 4];
                        Array.Copy(raw.recordData, 4, attrRecord.otherData, 0, attrRecord.otherData.Length);

                        inlineRecords.Add(attrRecord);
                        break;
                }
            }
        }