当前位置: 首页>>代码示例>>C#>>正文


C# IO.ReadInt16方法代码示例

本文整理汇总了C#中System.IO.ReadInt16方法的典型用法代码示例。如果您正苦于以下问题:C# IO.ReadInt16方法的具体用法?C# IO.ReadInt16怎么用?C# IO.ReadInt16使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO的用法示例。


在下文中一共展示了IO.ReadInt16方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetArchType

        private int GetArchType(sio.BinaryReader br, long len, out int fileCount)
        {
            sio.MemoryStream ms;
            long prevPos;
            long lastPos;
            byte b;
            byte[] bb;
            int size;
            int i;
            bool tru;

            bb = new byte[0xfc];

            ms = (sio.MemoryStream)br.BaseStream;
            fileCount = 0;
            prevPos = ms.Position;
            lastPos = prevPos + len;
            if (lastPos < 0x4)
                return 0;

            if (br.ReadInt32() == 0x64)
            {
                fileCount = br.ReadInt32();
                size = (fileCount + 1) << 3;
                if (fileCount > 0)
                    if (br.ReadInt32() == size)
                    {
                        ms.Position += size - 0xc - 0x8;
                        size = br.ReadInt32() + br.ReadInt32();
                        if (size <= lastPos)
                            return 1;
                    }
            }

            fileCount = 0;
            ms.Position = prevPos;
            if (lastPos > 0xff)
            {
                while (ms.Position < lastPos)
                {
                    for (i = 0; i < bb.Length; i++)
                    {
                        b = br.ReadByte();
                        if (b == 0)
                            break;
                        else if ((b < 0x20) || (b > 0x7f))
                        {
                            i = 0;
                            break;
                        }
                        bb[i] = b;
                    }
                    if (i > 0)
                    {
                        if (!stre.Regex.IsMatch(ste.ASCII.GetString(bb, 0, i), "^(\\w*[/.]*){1,}.\\w+$"))
                            break;
                    }
                    else if (fileCount == 0)
                        break;
                    ms.Position += bb.Length - i - 1;
                    size = br.ReadInt32();
                    if (size < 0 || size > lastPos)
                        break;
                    ms.Position += size;
                    ms.AlignPos(0x40);
                    if (size == 0)
                        if (fileCount == 0)
                            break;
                        else
                            if (lastPos - ms.Position < 0x800)
                                return 2;
                    fileCount++;
                }
                if (fileCount > 0)
                    if (ms.Position == lastPos)
                        return 2;
            }

            fileCount = 0;
            ms.Position = prevPos;
            if (br.ReadInt32() == 1)
                if (br.ReadInt32() == 0)
                    if (br.ReadInt32() == 0x30525053)
                        if (br.ReadInt32() == 0x20)
                            if (br.ReadInt32() - len - 0x4 < 0x40)
                            {
                                fileCount = br.ReadInt16();
                                return 3;
                            }
            #if DEBUG
                            else
                                throw new ArgumentException("spr0 size mismatch!");
                        else
                            throw new ArgumentException("spr0 header size mismatch!");
            #endif

            fileCount = 0;
            ms.Position = prevPos;
            if (br.ReadInt32() == 0)
                if (br.ReadInt32() - len - 0x4 < 0x40)
//.........这里部分代码省略.........
开发者ID:bsv798,项目名称:p3fes,代码行数:101,代码来源:arch.cs

示例2: ExtractSpr0

        private void ExtractSpr0(string extrPath, sio.BinaryReader br, long len)
        {
            sio.MemoryStream ms;
            long pos;
            int size;
            long prevPos;
            long startPos;
            int count;
            string name;
            int i;

            ms = (sio.MemoryStream)br.BaseStream;
            startPos = ms.Position;

            ms.Position += 0x14;
            count = br.ReadInt16();
            ms.Position += 0xa;
            prevPos = ms.Position;

            if (count == 0)
            {
                ms.Position = prevPos - 0x10;
                size = br.ReadInt32() - (int)(prevPos - startPos);
                ms.Position = prevPos;
            }
            else
            {
                br.ReadInt32();
                size = br.ReadInt32();
                ms.Position += (count - 1) << 0x3;
                size -= (int)(ms.Position - startPos);
            }
            name = misc.InsertCounter("dat", gFileCount++);
            GetArchs(extrPath, name, ms, size);

            for (i = 0; i < count; i++)
            {
                ms.Position = prevPos;
                br.ReadInt32();
                pos = br.ReadInt32();
                ms.Position = startPos + pos + 0x4;
                size = br.ReadInt32();
                ms.Position -= 0x8;
                name = misc.InsertCounter("tmx", gFileCount++);
                GetArchs(extrPath, name, ms, size);
                //sw.WriteLine(name);
                prevPos += 0x8;
            }
        }
开发者ID:bsv798,项目名称:p3fes,代码行数:49,代码来源:arch.cs

示例3: ExtractTmx0Ps2

        private void ExtractTmx0Ps2(string extrPath, sio.BinaryReader br, long len)
        {
            sio.MemoryStream ms;
            long startPos;
            long lastPos;
            long curPos;
            byte b;
            int size;
            bool found;
            string name;

            ms = (sio.MemoryStream)br.BaseStream;
            startPos = ms.Position;
            lastPos = startPos + len;
            curPos = ms.Position;
            size = 0;
            name = null;
            found = false;

            while (curPos < lastPos)
            {
                ms.Position = curPos;
                b = br.ReadByte();
                if (b == 0x2)
                {
                    if (br.ReadByte() == 0)
                        if (br.ReadInt16() == 0)
                        {
                            size = br.ReadInt32();
                            if (br.ReadInt32() == 0x30584D54) //tmx0
                                if (br.ReadInt32() == 0)
                                {
                                    name = misc.InsertCounter("tmx", gFileCount++);
                                    found = true;
                                }
                        }
                }
                else if (b == 0x15)
                {
                    if (br.ReadByte() == 0)
                        if (br.ReadInt16() == 0)
                        {
                            size = br.ReadInt32() + 0xc;
                            br.ReadInt32();
                            if (br.ReadInt32() == 1)
                                if (br.ReadInt32() == 0x8)
                                {
                                    ms.Position += 0x4;
                                    if (br.ReadInt32() == 0x325350) //ps2
                                    {
                                        name = misc.InsertCounter("ps2", gFileCount++);
                                        found = true;
                                    }
                                }
                        }
                }
                if (found)
                {
                    ms.Position = curPos;
                    sw.WriteLine(string.Format("{0:x8},{1:x8}", curPos - startPos, size));
                    sw.WriteLine(name);
                    ms.Extract(extrPath + name, size);
                    curPos += size - 1;
                    found = false;
                }
                curPos++;
            }
        }
开发者ID:bsv798,项目名称:p3fes,代码行数:68,代码来源:arch.cs

示例4: ExtractCin

        private void ExtractCin(string extrPath, sio.BinaryReader br, long len)
        {
            sio.MemoryStream ms;
            int count;
            long startPos;
            long pos;
            string name;

            ms = (sio.MemoryStream)br.BaseStream;
            startPos = ms.Position;

            ms.Position += 0x8;
            count = br.ReadInt16();
            ms.Position += 0x10;
            while (count > 0)
            {
                ms.Position += 0x11;
                if (br.ReadByte() == 0xfe)
                    count--;
            }
            ms.Position += 0xd;
            pos = ms.Position - startPos;
            pos = misc.Align(pos, 0x40);

            ms.Position = startPos;
            name = misc.InsertCounter("dat", gFileCount++);
            sw.WriteLine(name);
            ms.Extract(extrPath + name, pos);
            if (pos < (len - 0x100))
                GetArchs(extrPath, misc.InsertCounter("dat", gFileCount++), ms, len - (int)pos);
            else
                ms.Position = startPos + len;
        }
开发者ID:bsv798,项目名称:p3fes,代码行数:33,代码来源:arch.cs


注:本文中的System.IO.ReadInt16方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。