Пример #1
0
        public static CHD Load(Stream source)
        {
            CHD            result = new CHD(source);
            BinaryReaderEx reader = result.reader;

            if (new string(reader.ReadChars(8)) != "MComprHD")
            {
                return(null);
            }

            UInt32 headerLength = reader.ReadUInt32S();
            UInt32 version      = reader.ReadUInt32S();

            switch (version)
            {
            case 1:
                result.ReadHeaderV1();
                result.ReadMapV1();
                result.ReadHunk = result.ReadHunkV1;
                break;

            case 2:
                result.ReadHeaderV2();
                result.ReadMapV1();
                result.ReadHunk = result.ReadHunkV1;
                break;

            case 3:
                result.ReadHeaderV3();
                result.ReadMapV3();
                result.ReadHunk = result.ReadHunkV3;
                break;

            case 4:
                result.ReadHeaderV4();
                result.ReadMapV3();
                result.ReadHunk = result.ReadHunkV3;
                break;

            case 5:
                result.ReadHeaderV5();
                result.ReadMapV5();
                result.ReadHunk = result.ReadHunkV5;
                break;

            default:
                return(null);
            }

            return(result);
        }
Пример #2
0
        public static CHD Load(Stream source)
        {
            CHD result = new CHD(source);
            BinaryReaderEx reader = result.reader;

            if (new string(reader.ReadChars(8)) != "MComprHD")
                return null;

            UInt32 headerLength = reader.ReadUInt32S();
            UInt32 version = reader.ReadUInt32S();

            switch (version)
            {
                case 1:
                    result.ReadHeaderV1();
                    result.ReadMapV1();
                    result.ReadHunk = result.ReadHunkV1;
                    break;
                case 2:
                    result.ReadHeaderV2();
                    result.ReadMapV1();
                    result.ReadHunk = result.ReadHunkV1;
                    break;
                case 3:
                    result.ReadHeaderV3();
                    result.ReadMapV3();
                    result.ReadHunk = result.ReadHunkV3;
                    break;
                case 4:
                    result.ReadHeaderV4();
                    result.ReadMapV3();
                    result.ReadHunk = result.ReadHunkV3;
                    break;
                case 5:
                    result.ReadHeaderV5();
                    result.ReadMapV5();
                    result.ReadHunk = result.ReadHunkV5;
                    break;
                default:
                    return null;
            }

            return result;
        }