Example #1
0
            private uint selflen;            //子要素を除く長さ

            //constructor
            public mwgIffDir(byte[] data, uint offset)
            {
                uint i = offset;

                //id
                identifier = new mwgFourcc(data, i);
                if ((string)(identifier) != "DIR ")
                {
                    throw new System.Exception("mwgIff データの読み取り中にエラーが発生しました。ディレクトリでない情報を誤ってディレクトリ'DIR 'として処理しようとしました。");
                }
                i += 4;
                //name
                name = new mfString(data, i);
                i   += this.name.Length;
                //made,lastmodified
                this.madetime = new mfTime(data, i); i += 5;
                this.lasttime = new mfTime(data, i); i += 5;
                //data
                annex = new mfString(data, i);
                i    += this.annex.Length;
                //子要素の最後
                uint imax = i + 4 + (uint)(new mwgDword(data, i));

                if (imax > data.Length)
                {
                    imax = (uint)data.Length;
                }
                i           += 4;
                this.selflen = i;
                //◆以上 runover の可能性在り

                //子要素
                while (i < imax)
                {
                    switch ((string)(new mwgFourcc(data, i)))
                    {
                    case "DIR ":
                        childs.Add(new mwgIffDir(data, i));
                        break;

                    case "FILE":
                        childs.Add(new mwgIffFile(data, i));
                        break;

                    default:
                        childs.Add(new mwgIffData(data, i));
                        break;
                    }
                    i += (uint)childs.Item(childs.Length - 1).Length;
                }
            }
Example #2
0
        //=====================================
        //          constructor
        //-------------------------------------
        public mwgIff(string filename)
        {
            System.Text.UnicodeEncoding uni = new System.Text.UnicodeEncoding();
            uint i, imax;

            byte[] data = mwg.File.mwgBinary.WholeFileInBinary(filename);
            imax      = (uint)data.Length;
            this.path = filename;

            //ファイル識別子の確認とversion の取得
            if ((string)(new mwgFourcc(data, 0)) != "mIff")
            {
                return;                                                   //◆
            }
            this.version = (uint)(new mwgDword(data, 4)); i = 8;
            //内部ファイル名(ディレクトリ名)の取得
            this.name = new mfString(data, i); i += this.name.Length;
            //年月日の取得
            this.madetime = new mfTime(data, i); i += 5;
            this.lasttime = new mfTime(data, i); i += 5;
            //固有情報(annex)の取得
            this.annex = new mfString(data, i); i += this.annex.Length;
            //子要素の取得
            uint x = i + (uint)(new mwgDword(data, i)); i += 4;

            if (x < imax)
            {
                imax = x;
            }
            while (i < imax)
            {
                switch ((string)(new mwgFourcc(data, i)))
                {
                case "DIR ":
                    childs.Add(new mwgIffDir(data, i));
                    break;

                case "FILE":
                    childs.Add(new mwgIffFile(data, i));
                    break;

                default:
                    childs.Add(new mwgIffData(data, i));
                    break;
                }
                i += childs.Item(childs.Length - 1).Length;
            }
        }
Example #3
0
            //constructor
            public mwgIffFile(byte[] data, uint offset)
            {
                uint i = offset;

                //id
                identifier = new mwgFourcc(data, i);
                if ((string)(identifier) != "FILE")
                {
                    throw new System.Exception("mwgIff データの読み取り中にエラーが発生しました。ファイルでない情報を誤ってファイル'FILE'として処理しようとしました。");
                }
                i += 4;
                //name
                name = new mfString(data, i);
                i   += this.name.Length;
                //made,lastmodified
                this.madetime = new mfTime(data, i); i += 5;
                this.lasttime = new mfTime(data, i); i += 5;
                //data
                this.content = new mfBytes(data, i);
                i           += this.content.Length;
                //子要素の最後(postLen)
                uint imax = i + 4 + (uint)(new mwgDword(data, i));

                if (imax > data.Length)
                {
                    imax = (uint)data.Length;
                }
                i           += 4;
                this.selflen = i;
                //◆以上 runover の可能性在り

                //子要素の登録
                while (i < imax)
                {
                    childs.Add(new mwgIffData(data, i));
                    i += childs.Item(childs.Length - 1).Length;
                }
            }