コード例 #1
0
        public void Format()
        {
            SuperBlock = new SuperBlock
            {
                BlockSize           = 2, //this should be calculated
                TotalReservedBlocks = 20,
                TotalBlocks         = BlockDevice.TotalBlocks,
                SizeOfIndexInBytes  = 0,
                Checksum            = 0,
                DataSizeInBlocks    = 0,
                TimeStamp           = 0
            };

            SuperBlock.SizeOfIndexInBytes = 64 * 2;
            SuperBlock.Write(BlockBuffer);


            var volumeIdentifier = new VolumeIdentifier
            {
                TimeStamp  = 0,
                VolumeName = "SFS Volume"
            };

            var offset = 1;

            BlockBuffer.Offset = BlockDevice.BlockSize * BlockDevice.TotalBlocks - offset * 64;

            volumeIdentifier.Write(BlockBuffer);
            offset++;

            BlockBuffer.Offset = BlockDevice.BlockSize * BlockDevice.TotalBlocks - offset * 64;

            var marker = new StartingMarkerEntry();

            marker.Write(BlockBuffer);

            ReadIndexAria();
        }
コード例 #2
0
        private void ReadIndexAria()
        {
            IndexAria.Clear();

            var endOfVolume = BlockDevice.BlockSize * BlockDevice.TotalBlocks;
            var offset      = 1;

            while (endOfVolume > offset * 64)
            {
                BlockBuffer.Offset = endOfVolume - offset * 64;

                var id = BlockBuffer.ReadByte();
                BlockBuffer.Offset--;

                switch (id)
                {
                case 0x01:     // VolumeIdentifier
                {
                    var x = new VolumeIdentifier();
                    x.Read(BlockBuffer);
                    IndexAria.Add(x);
                }
                break;

                case 0x02:     // Starting Marker Entry
                {
                    var x = new StartingMarkerEntry();
                    x.Read(BlockBuffer);
                    IndexAria.Add(x);
                    return;
                }

                case 0x10:     // Unused Entry
                {
                    var x = new UnusedEntry();
                    x.Read(BlockBuffer);
                    IndexAria.Add(x);
                }
                break;

                case 0x11:     // Directory Entry
                {
                    var x = new DirectoryEntry();
                    x.Read(BlockBuffer);
                    IndexAria.Add(x);
                    if (x.Continuations > 0)
                    {
                        offset            += x.Continuations + 1;
                        BlockBuffer.Offset = endOfVolume - offset * 64;
                        x.Name             = BlockBuffer.ReadString();
                    }
                }
                break;

                case 0x12:     // File Entry
                {
                    var x = new FileEntry();
                    x.Read(BlockBuffer);
                    IndexAria.Add(x);

                    if (x.Continuations > 0)
                    {
                        offset            += x.Continuations + 1;
                        BlockBuffer.Offset = endOfVolume - offset * 64;
                        x.Name             = BlockBuffer.ReadString();
                    }
                }
                break;

                case 0x18:     // Unusable Entry
                {
                    var x = new UnusableEntry();
                    x.Read(BlockBuffer);
                    IndexAria.Add(x);
                }
                break;

                case 0x19:     // Deleted Directory Entry
                {
                    var x = new DeletedDirectoryEntry();
                    x.Read(BlockBuffer);
                    IndexAria.Add(x);

                    if (x.Continuations > 0)
                    {
                        offset            += x.Continuations + 1;
                        BlockBuffer.Offset = endOfVolume - offset * 64;
                        x.Name             = BlockBuffer.ReadString();
                    }
                }
                break;

                case 0x1A:     // Deleted File Entry
                {
                    var x = new DeletedFileEntry();
                    x.Read(BlockBuffer);
                    IndexAria.Add(x);

                    if (x.Continuations > 0)
                    {
                        offset            += x.Continuations + 1;
                        BlockBuffer.Offset = endOfVolume - offset * 64;
                        x.Name             = BlockBuffer.ReadString();
                    }
                }
                break;
                }

                offset++;
            }
        }