Beispiel #1
0
    public static long ReadLong(byte[] data, ref int offset)
    {
        int num  = CMemoryManager.ReadInt(data, ref offset);
        int num2 = CMemoryManager.ReadInt(data, ref offset);

        return((long)num2 << 32 | (long)num);
    }
    public void Read(byte[] data, ref int offset)
    {
        if (data == null || offset < 0 || offset >= data.Length)
        {
            return;
        }
        int num = offset;

        if (CMemoryManager.ReadInt(data, ref offset) > data.Length - num)
        {
            return;
        }
        this.m_version     = CMemoryManager.ReadString(data, ref offset);
        this.m_buildNumber = CMemoryManager.ReadString(data, ref offset);
        this.m_publish     = CMemoryManager.ReadString(data, ref offset);
        this.m_ifsPath     = CMemoryManager.ReadString(data, ref offset);
        int num2 = CMemoryManager.ReadShort(data, ref offset);

        this.m_resourcePackerInfosAll.Clear();
        for (int i = 0; i < num2; i++)
        {
            CResourcePackerInfo cResourcePackerInfo = new CResourcePackerInfo(false);
            cResourcePackerInfo.Read(data, ref offset);
            this.AddResourcePackerInfo(cResourcePackerInfo);
        }
    }
Beispiel #3
0
    public static void WriteString(string str, byte[] data, ref int offset)
    {
        int bytes = Encoding.get_UTF8().GetBytes(str, 0, str.get_Length(), data, offset + 2);

        CMemoryManager.WriteShort((short)bytes, data, ref offset);
        offset += bytes;
    }
Beispiel #4
0
 public void Read(byte[] data, ref int offset)
 {
     this.m_cachedTextureInfos.Clear();
     this.m_cachedTextureInfoMap.Clear();
     if (data != null)
     {
         int num = data.Length - offset;
         if (num >= 6)
         {
             int num2 = CMemoryManager.ReadInt(data, ref offset);
             if (((num2 >= 6) && (num2 <= num)) && (CMemoryManager.ReadShort(data, ref offset) == 0x2713))
             {
                 int num4 = CMemoryManager.ReadShort(data, ref offset);
                 for (int i = 0; i < num4; i++)
                 {
                     CCachedTextureInfo info = new CCachedTextureInfo {
                         m_key            = CMemoryManager.ReadString(data, ref offset),
                         m_width          = CMemoryManager.ReadShort(data, ref offset),
                         m_height         = CMemoryManager.ReadShort(data, ref offset),
                         m_lastModifyTime = CMemoryManager.ReadDateTime(data, ref offset),
                         m_isGif          = CMemoryManager.ReadByte(data, ref offset) > 0
                     };
                     if (!this.m_cachedTextureInfoMap.ContainsKey(info.m_key))
                     {
                         this.m_cachedTextureInfoMap.Add(info.m_key, info);
                         this.m_cachedTextureInfos.Add(info);
                     }
                 }
                 this.m_cachedTextureInfos.Sort();
             }
         }
     }
 }
Beispiel #5
0
    public static void WriteLong(long value, byte[] data, ref int offset)
    {
        int value2 = (int)value;
        int value3 = (int)(value >> 32);

        CMemoryManager.WriteInt(value2, data, ref offset);
        CMemoryManager.WriteInt(value3, data, ref offset);
    }
Beispiel #6
0
    public static string ReadString(byte[] data, ref int offset)
    {
        int    num     = CMemoryManager.ReadShort(data, ref offset);
        string @string = Encoding.get_UTF8().GetString(data, offset, num);

        offset += num;
        return(@string);
    }
Beispiel #7
0
 public void Write(byte[] buffer, ref int offset)
 {
     CMemoryManager.WriteString(m_key, buffer, ref offset);
     CMemoryManager.WriteInt(m_fileLength, buffer, ref offset);
     CMemoryManager.WriteDateTime(ref m_lastModifyTime, buffer, ref offset);
     CMemoryManager.WriteInt(m_tagInt1, buffer, ref offset);
     CMemoryManager.WriteInt(m_tagInt2, buffer, ref offset);
     CMemoryManager.WriteByte((byte)(m_tagBool ? 1 : 0), buffer, ref offset);
 }
Beispiel #8
0
 public void Read(byte[] buffer, ref int offset)
 {
     m_key            = CMemoryManager.ReadString(buffer, ref offset);
     m_fileLength     = CMemoryManager.ReadInt(buffer, ref offset);
     m_lastModifyTime = CMemoryManager.ReadDateTime(buffer, ref offset);
     m_tagInt1        = CMemoryManager.ReadInt(buffer, ref offset);
     m_tagInt2        = CMemoryManager.ReadInt(buffer, ref offset);
     m_tagBool        = (CMemoryManager.ReadByte(buffer, ref offset) > 0);
 }
Beispiel #9
0
 public void Write(byte[] data, ref int offset)
 {
     CMemoryManager.WriteString(this.m_version, data, ref offset);
     CMemoryManager.WriteString(this.m_publish, data, ref offset);
     CMemoryManager.WriteString(this.m_ifsPath, data, ref offset);
     CMemoryManager.WriteShort((short)this.m_resourcePackerInfosInTreeStruct.Count, data, ref offset);
     for (int i = 0; i < this.m_resourcePackerInfosInTreeStruct.Count; i++)
     {
         this.m_resourcePackerInfosInTreeStruct[i].Write(data, ref offset);
     }
 }
Beispiel #10
0
 public void Write(byte[] data, ref int offset)
 {
     CMemoryManager.WriteShort(0x2712, data, ref offset);
     CMemoryManager.WriteShort((short)this.m_cachedTextureInfos.Count, data, ref offset);
     for (int i = 0; i < this.m_cachedTextureInfos.Count; i++)
     {
         CMemoryManager.WriteString(this.m_cachedTextureInfos[i].m_key, data, ref offset);
         CMemoryManager.WriteShort((short)this.m_cachedTextureInfos[i].m_width, data, ref offset);
         CMemoryManager.WriteShort((short)this.m_cachedTextureInfos[i].m_height, data, ref offset);
         CMemoryManager.WriteDateTime(ref this.m_cachedTextureInfos[i].m_lastModifyTime, data, ref offset);
         CMemoryManager.WriteByte(!this.m_cachedTextureInfos[i].m_isGif ? ((byte)0) : ((byte)1), data, ref offset);
     }
 }
 public static void ReadVersionAndBuildNumber(byte[] data, ref int offset, ref string version, ref string buildNumber)
 {
     version     = CVersion.s_emptyResourceVersion;
     buildNumber = CVersion.s_emptyBuildNumber;
     if (((data != null) && (offset >= 0)) && (offset < data.Length))
     {
         int num = offset;
         if (CMemoryManager.ReadInt(data, ref offset) <= (data.Length - num))
         {
             version     = CMemoryManager.ReadString(data, ref offset);
             buildNumber = CMemoryManager.ReadString(data, ref offset);
         }
     }
 }
Beispiel #12
0
    public void Read(byte[] data, ref int offset)
    {
        this.m_version = CMemoryManager.ReadString(data, ref offset);
        this.m_publish = CMemoryManager.ReadString(data, ref offset);
        this.m_ifsPath = CMemoryManager.ReadString(data, ref offset);
        int num = CMemoryManager.ReadShort(data, ref offset);

        this.m_resourcePackerInfosInTreeStruct.Clear();
        this.m_resourcePackerInfosAll.Clear();
        for (int i = 0; i < num; i++)
        {
            CResourcePackerInfo resourceInfo = new CResourcePackerInfo(false);
            resourceInfo.Read(data, ref offset);
            this.AddResourcePackerInfo(resourceInfo);
        }
    }
Beispiel #13
0
    //--------------------------------------------------
    /// 读出数据
    /// @buffer
    /// @offset
    /// @dataLength
    //--------------------------------------------------
    public int Read(byte[] buffer, int offset, uint dataLength)
    {
        m_cachedFileInfos.Clear();
        m_cachedFileInfoMap.Clear();

        //数据长度不合法,不能读取数据
        if (dataLength < 6 || offset + (int)dataLength > buffer.Length)
        {
            return(-1);
        }

        //校验数据长度
        int storedDataLength = CMemoryManager.ReadInt(buffer, ref offset);

        if (storedDataLength < 6 || storedDataLength != (int)dataLength)
        {
            return(-2);
        }

        //校验版本号
        int version = CMemoryManager.ReadShort(buffer, ref offset);

        if (version != c_version)
        {
            return(-3);
        }

        //读取数据
        int infoAmount = CMemoryManager.ReadShort(buffer, ref offset);

        for (int i = 0; i < infoAmount; i++)
        {
            CCachedFileInfo cacheFileInfo = new CCachedFileInfo();
            cacheFileInfo.Read(buffer, ref offset);

            //防止key重复
            if (m_cachedFileInfoMap.ContainsKey(cacheFileInfo.m_key) == false)
            {
                m_cachedFileInfoMap.Add(cacheFileInfo.m_key, cacheFileInfo);
                m_cachedFileInfos.Add(cacheFileInfo);
            }
        }
        //按最后修改时间排序
        m_cachedFileInfos.Sort();
        return(0);
    }
    public static void ReadVersionAndBuildNumber(byte[] data, ref int offset, ref string version, ref string buildNumber)
    {
        version     = CVersion.s_emptyResourceVersion;
        buildNumber = CVersion.s_emptyBuildNumber;
        if (data == null || offset < 0 || offset >= data.Length)
        {
            return;
        }
        int num = offset;

        if (CMemoryManager.ReadInt(data, ref offset) > data.Length - num)
        {
            return;
        }
        version     = CMemoryManager.ReadString(data, ref offset);
        buildNumber = CMemoryManager.ReadString(data, ref offset);
    }
        public void Write(byte[] data, ref int offset)
        {
            int num = offset;

            offset += 4;
            CMemoryManager.WriteShort(10003, data, ref offset);
            CMemoryManager.WriteShort((short)this.m_cachedTextureInfos.get_Count(), data, ref offset);
            for (int i = 0; i < this.m_cachedTextureInfos.get_Count(); i++)
            {
                CMemoryManager.WriteString(this.m_cachedTextureInfos.get_Item(i).m_key, data, ref offset);
                CMemoryManager.WriteShort((short)this.m_cachedTextureInfos.get_Item(i).m_width, data, ref offset);
                CMemoryManager.WriteShort((short)this.m_cachedTextureInfos.get_Item(i).m_height, data, ref offset);
                CMemoryManager.WriteDateTime(ref this.m_cachedTextureInfos.get_Item(i).m_lastModifyTime, data, ref offset);
                CMemoryManager.WriteByte((!this.m_cachedTextureInfos.get_Item(i).m_isGif) ? 0 : 1, data, ref offset);
            }
            CMemoryManager.WriteInt(offset - num, data, ref num);
        }
 public void Write(byte[] data, ref int offset)
 {
     if (((data != null) && (offset >= 0)) && (offset < data.Length))
     {
         int num = offset;
         offset += 4;
         CMemoryManager.WriteString(this.m_version, data, ref offset);
         CMemoryManager.WriteString(this.m_buildNumber, data, ref offset);
         CMemoryManager.WriteString(this.m_publish, data, ref offset);
         CMemoryManager.WriteString(this.m_ifsPath, data, ref offset);
         CMemoryManager.WriteShort((short)this.m_resourcePackerInfosInTreeStruct.Count, data, ref offset);
         for (int i = 0; i < this.m_resourcePackerInfosInTreeStruct.Count; i++)
         {
             this.m_resourcePackerInfosInTreeStruct[i].Write(data, ref offset);
         }
         CMemoryManager.WriteInt(offset, data, ref num);
     }
 }
        public void Read(byte[] data, ref int offset)
        {
            this.m_cachedTextureInfos.Clear();
            this.m_cachedTextureInfoMap.Clear();
            if (data == null)
            {
                return;
            }
            int num = data.Length - offset;

            if (num < 6)
            {
                return;
            }
            int num2 = CMemoryManager.ReadInt(data, ref offset);

            if (num2 < 6 || num2 > num)
            {
                return;
            }
            int num3 = CMemoryManager.ReadShort(data, ref offset);

            if (num3 != 10003)
            {
                return;
            }
            int num4 = CMemoryManager.ReadShort(data, ref offset);

            for (int i = 0; i < num4; i++)
            {
                CCachedTextureInfo cCachedTextureInfo = new CCachedTextureInfo();
                cCachedTextureInfo.m_key            = CMemoryManager.ReadString(data, ref offset);
                cCachedTextureInfo.m_width          = CMemoryManager.ReadShort(data, ref offset);
                cCachedTextureInfo.m_height         = CMemoryManager.ReadShort(data, ref offset);
                cCachedTextureInfo.m_lastModifyTime = CMemoryManager.ReadDateTime(data, ref offset);
                cCachedTextureInfo.m_isGif          = (CMemoryManager.ReadByte(data, ref offset) > 0);
                if (!this.m_cachedTextureInfoMap.ContainsKey(cCachedTextureInfo.m_key))
                {
                    this.m_cachedTextureInfoMap.Add(cCachedTextureInfo.m_key, cCachedTextureInfo);
                    this.m_cachedTextureInfos.Add(cCachedTextureInfo);
                }
            }
            this.m_cachedTextureInfos.Sort();
        }
    public virtual void Read(byte[] data, ref int offset)
    {
        this.m_isAssetBundle = (CMemoryManager.ReadByte(data, ref offset) > 0);
        this.m_pathInIFS     = CMemoryManager.ReadString(data, ref offset);
        this.m_tag           = CMemoryManager.ReadString(data, ref offset);
        this.m_flags         = (ushort)CMemoryManager.ReadInt(data, ref offset);
        int num = CMemoryManager.ReadShort(data, ref offset);

        this.m_resourceInfos.Clear();
        if (!this.m_isAssetBundle)
        {
            this.m_fileExtMap = new Dictionary <int, string>();
        }
        for (int i = 0; i < num; i++)
        {
            stResourceInfo stResourceInfo = new stResourceInfo();
            string         s = CMemoryManager.ReadString(data, ref offset);
            stResourceInfo.m_hashCode = s.JavaHashCodeIgnoreCase();
            stResourceInfo.extension  = CMemoryManager.ReadString(data, ref offset);
            stResourceInfo.m_flags    = (byte)CMemoryManager.ReadInt(data, ref offset);
            bool flag = CMemoryManager.ReadByte(data, ref offset) > 0;
            if (flag)
            {
                stResourceInfo.m_fullPathInResourcesWithoutExtension_Renamed = CMemoryManager.ReadString(data, ref offset);
            }
            if (!this.m_isAssetBundle)
            {
                string text = stResourceInfo.extension.Replace(".", string.Empty);
                this.m_fileExtMap.set_Item(stResourceInfo.m_hashCode, text);
            }
            this.m_resourceInfos.Add(stResourceInfo);
        }
        num = CMemoryManager.ReadShort(data, ref offset);
        this.m_children.Clear();
        for (int j = 0; j < num; j++)
        {
            CResourcePackerInfo cResourcePackerInfo = new CResourcePackerInfo(true);
            cResourcePackerInfo.Read(data, ref offset);
            cResourcePackerInfo.dependency = this;
        }
    }
Beispiel #19
0
    //--------------------------------------------------
    /// 写入数据
    /// @buffer
    /// @offset
    //--------------------------------------------------
    public void Write(byte[] buffer, ref int offset)
    {
        int startOffset = offset;

        //跳过文件长度
        offset += 4;

        //写入版本号
        CMemoryManager.WriteShort((short)c_version, buffer, ref offset);

        //写入info数量
        CMemoryManager.WriteShort((short)m_cachedFileInfos.Count, buffer, ref offset);

        //写入数据
        for (int i = 0; i < m_cachedFileInfos.Count; i++)
        {
            m_cachedFileInfos[i].Write(buffer, ref offset);
        }

        //写入文件长度
        CMemoryManager.WriteInt(offset - startOffset, buffer, ref startOffset);
    }
 public void Read(byte[] data, ref int offset)
 {
     if (((data != null) && (offset >= 0)) && (offset < data.Length))
     {
         int num = offset;
         if (CMemoryManager.ReadInt(data, ref offset) <= (data.Length - num))
         {
             this.m_version     = CMemoryManager.ReadString(data, ref offset);
             this.m_buildNumber = CMemoryManager.ReadString(data, ref offset);
             this.m_publish     = CMemoryManager.ReadString(data, ref offset);
             this.m_ifsPath     = CMemoryManager.ReadString(data, ref offset);
             int num2 = CMemoryManager.ReadShort(data, ref offset);
             this.m_resourcePackerInfosInTreeStruct.Clear();
             this.m_resourcePackerInfosAll.Clear();
             for (int i = 0; i < num2; i++)
             {
                 CResourcePackerInfo resourceInfo = new CResourcePackerInfo(false);
                 resourceInfo.Read(data, ref offset);
                 this.AddResourcePackerInfo(resourceInfo);
             }
         }
     }
 }