예제 #1
0
        private void ReadInvitedFriendDicFromBinFile()
        {
            string     cachePath  = CFileManager.GetCachePath("invited_friend_02_" + Singleton <CRoleInfoManager> .GetInstance().GetMasterRoleInfo().playerUllUID);
            FileStream fileStream = null;

            if (!CFileManager.IsFileExist(cachePath))
            {
                return;
            }
            try
            {
                fileStream = new FileStream(cachePath, 3, 1, 0);
                BinaryFormatter binaryFormatter = new BinaryFormatter();
                this.m_InvitedFriendDic = (Dictionary <ulong, stInvitedFriend>)binaryFormatter.Deserialize(fileStream);
                fileStream.Close();
                fileStream.Dispose();
            }
            catch (Exception var_3_65)
            {
                if (fileStream != null)
                {
                    fileStream.Close();
                    fileStream.Dispose();
                }
            }
        }
    public static int GetFileLength(string filePath)
    {
        if (!CFileManager.IsFileExist(filePath))
        {
            return(0);
        }
        int num = 0;
        int result;

        while (true)
        {
            try
            {
                FileInfo fileInfo = new FileInfo(filePath);
                result = (int)fileInfo.get_Length();
                break;
            }
            catch (Exception ex)
            {
                num++;
                if (num >= 3)
                {
                    Debug.Log("Get FileLength of " + filePath + " Error! Exception = " + ex.ToString());
                    result = 0;
                    break;
                }
            }
        }
        return(result);
    }
예제 #3
0
        private void ReadInvitedFriendDicFromBinFile()
        {
            string     cachePath           = CFileManager.GetCachePath("invited_friend_02_" + Singleton <CRoleInfoManager> .GetInstance().GetMasterRoleInfo().playerUllUID);
            FileStream serializationStream = null;

            if (CFileManager.IsFileExist(cachePath))
            {
                try
                {
                    serializationStream = new FileStream(cachePath, FileMode.Open, FileAccess.Read, FileShare.None);
                    BinaryFormatter formatter = new BinaryFormatter();
                    this.m_InvitedFriendDic = (Dictionary <ulong, stInvitedFriend>)formatter.Deserialize(serializationStream);
                    serializationStream.Close();
                    serializationStream.Dispose();
                }
                catch (Exception)
                {
                    if (serializationStream != null)
                    {
                        serializationStream.Close();
                        serializationStream.Dispose();
                    }
                }
            }
        }
예제 #4
0
        private void WriteInvitedFriendDicToBinFile()
        {
            string     cachePath           = CFileManager.GetCachePath("invited_friend_02_" + Singleton <CRoleInfoManager> .GetInstance().GetMasterRoleInfo().playerUllUID);
            FileStream serializationStream = null;

            try
            {
                if (!CFileManager.IsFileExist(cachePath))
                {
                    serializationStream = new FileStream(cachePath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
                }
                else
                {
                    serializationStream = new FileStream(cachePath, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite);
                }
                new BinaryFormatter().Serialize(serializationStream, this.m_InvitedFriendDic);
                serializationStream.Flush();
                serializationStream.Close();
                serializationStream.Dispose();
            }
            catch (Exception)
            {
                if (serializationStream != null)
                {
                    serializationStream.Close();
                    serializationStream.Dispose();
                }
            }
        }
예제 #5
0
    public static byte[] ReadFile(string path)
    {
        FileStream stream = null;

        if (CFileManager.IsFileExist(path))
        {
            try
            {
                stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.None);
                int    length = (int)stream.Length;
                byte[] array  = new byte[length];
                stream.Read(array, 0, length);
                stream.Close();
                stream.Dispose();
                return(array);
            }
            catch (Exception)
            {
                if (stream != null)
                {
                    stream.Close();
                    stream.Dispose();
                }
            }
        }
        return(null);
    }
예제 #6
0
        public Texture2D GetCachedTexture(string url)
        {
            string             key = CFileManager.GetMd5(url.ToLower());
            CCachedTextureInfo cachedTextureInfo = this.m_cachedTextureInfoSet.GetCachedTextureInfo(key);

            if (cachedTextureInfo != null)
            {
                TimeSpan span = (TimeSpan)(DateTime.Now - cachedTextureInfo.m_lastModifyTime);
                if (span.TotalDays < 2.0)
                {
                    string filePath = CFileManager.CombinePath(s_cachedTextureDirectory, key + ".bytes");
                    if (!CFileManager.IsFileExist(filePath))
                    {
                        return(null);
                    }
                    byte[] buffer = CFileManager.ReadFile(filePath);
                    if ((buffer == null) || (buffer.Length <= 0))
                    {
                        return(null);
                    }
                    Texture2D textured = null;
                    if (cachedTextureInfo.m_isGif)
                    {
                        using (MemoryStream stream = new MemoryStream(buffer))
                        {
                            return(GifHelper.GifToTexture(stream, 0));
                        }
                    }
                    textured = new Texture2D(cachedTextureInfo.m_width, cachedTextureInfo.m_height, TextureFormat.ARGB32, false);
                    textured.LoadImage(buffer);
                    return(textured);
                }
            }
            return(null);
        }
예제 #7
0
    //--------------------------------------------------
    /// 构造函数
    //--------------------------------------------------
    public CHttpFileCacher(int max, string folderName, string fileExtension)
    {
        m_maxCnt        = max;
        m_dir           = GetCacheDirectory(folderName.ToLower());
        m_metaFilePath  = CFileManager.CombinePath(m_dir, folderName.ToLower() + ".bytes");
        m_fileExtension = fileExtension;

        m_cachedFileInfoSet = new CCachedFileInfoSet();

        MakeDirReady();

        if (CFileManager.IsFileExist(m_metaFilePath))
        {
            byte[] buffer = CFileManager.LockFileBuffer();

            try
            {
                uint fileLength = CFileManager.ReadFile(m_metaFilePath, buffer, (uint)buffer.Length);
                int  offset     = 0;

                int ret = m_cachedFileInfoSet.Read(buffer, offset, fileLength);

                if (ret < 0)    //读取出错时,删除所有文件
                {
                    Debug.LogError("读取出错,删除所有文件");
                    CFileManager.ClearDirectory(m_dir);
                }
            }
            finally
            {
                CFileManager.UnLockFileBuffer();
            }
        }
    }
예제 #8
0
    public static bool WriteFile(string path, byte[] bytes)
    {
        FileStream stream = null;

        try
        {
            if (!CFileManager.IsFileExist(path))
            {
                stream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
            }
            else
            {
                stream = new FileStream(path, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite);
            }
            stream.Write(bytes, 0, bytes.Length);
            stream.Flush();
            stream.Close();
            stream.Dispose();
            return(true);
        }
        catch (Exception)
        {
            if (stream != null)
            {
                stream.Close();
                stream.Dispose();
            }
            return(false);
        }
    }
예제 #9
0
파일: Utility.cs 프로젝트: PenpenLi/Hifior
    public static byte[] ReadFile(string path)
    {
        FileStream fileStream = null;

        if (!CFileManager.IsFileExist(path))
        {
            return(null);
        }
        try
        {
            fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.None);
            int    num   = (int)fileStream.Length;
            byte[] array = new byte[num];
            fileStream.Read(array, 0, num);
            fileStream.Close();
            fileStream.Dispose();
            return(array);
        }
        catch (Exception)
        {
            if (fileStream != null)
            {
                fileStream.Close();
                fileStream.Dispose();
            }
        }
        return(null);
    }
    public static bool DeleteFile(string filePath)
    {
        if (!CFileManager.IsFileExist(filePath))
        {
            return(true);
        }
        int  num = 0;
        bool result;

        while (true)
        {
            try
            {
                File.Delete(filePath);
                result = true;
                break;
            }
            catch (Exception ex)
            {
                num++;
                if (num >= 3)
                {
                    Debug.Log("Delete File " + filePath + " Error! Exception = " + ex.ToString());
                    CFileManager.s_delegateOnOperateFileFail(filePath, enFileOperation.DeleteFile, ex);
                    result = false;
                    break;
                }
            }
        }
        return(result);
    }
예제 #11
0
        private void WriteInvitedFriendDicToBinFile()
        {
            string     cachePath  = CFileManager.GetCachePath("invited_friend_02_" + Singleton <CRoleInfoManager> .GetInstance().GetMasterRoleInfo().playerUllUID);
            FileStream fileStream = null;

            try
            {
                if (!CFileManager.IsFileExist(cachePath))
                {
                    fileStream = new FileStream(cachePath, 2, 2, 3);
                }
                else
                {
                    fileStream = new FileStream(cachePath, 5, 2, 3);
                }
                BinaryFormatter binaryFormatter = new BinaryFormatter();
                binaryFormatter.Serialize(fileStream, this.m_InvitedFriendDic);
                fileStream.Flush();
                fileStream.Close();
                fileStream.Dispose();
            }
            catch (Exception var_3_74)
            {
                if (fileStream != null)
                {
                    fileStream.Close();
                    fileStream.Dispose();
                }
            }
        }
 public static string GetFileMd5(string filePath)
 {
     if (!CFileManager.IsFileExist(filePath))
     {
         return(string.Empty);
     }
     return(BitConverter.ToString(CFileManager.s_md5Provider.ComputeHash(CFileManager.ReadFile(filePath))).Replace("-", string.Empty));
 }
    public static byte[] ReadFile(string filePath)
    {
        if (!CFileManager.IsFileExist(filePath))
        {
            return(null);
        }
        byte[]    array = null;
        int       num   = 0;
        Exception ex;

        while (true)
        {
            ex = null;
            try
            {
                array = File.ReadAllBytes(filePath);
            }
            catch (Exception ex2)
            {
                Debug.Log(string.Concat(new object[]
                {
                    "Read File ",
                    filePath,
                    " Error! Exception = ",
                    ex2.ToString(),
                    ", TryCount = ",
                    num
                }));
                array = null;
                ex    = ex2;
            }
            if (array != null && array.Length > 0)
            {
                break;
            }
            num++;
            if (num >= 3)
            {
                goto Block_5;
            }
        }
        return(array);

Block_5:
        Debug.Log(string.Concat(new object[]
        {
            "Read File ",
            filePath,
            " Fail!, TryCount = ",
            num
        }));
        CFileManager.s_delegateOnOperateFileFail(filePath, enFileOperation.ReadFile, ex);
        return(null);
    }
예제 #14
0
        public void AddCachedTexture(string url, int width, int height, bool isGif, byte[] data)
        {
            string key = CFileManager.GetMd5(url.ToLower());

            if (this.m_cachedTextureInfoSet.m_cachedTextureInfoMap.ContainsKey(key))
            {
                CCachedTextureInfo info = null;
                this.m_cachedTextureInfoSet.m_cachedTextureInfoMap.TryGetValue(key, out info);
                DebugHelper.Assert(this.m_cachedTextureInfoSet.m_cachedTextureInfos.Contains(info), "zen me ke neng?");
                info.m_width          = width;
                info.m_height         = height;
                info.m_lastModifyTime = DateTime.Now;
                info.m_isGif          = isGif;
            }
            else
            {
                if (this.m_cachedTextureInfoSet.m_cachedTextureInfos.Count >= 100)
                {
                    string str2 = this.m_cachedTextureInfoSet.RemoveEarliestTextureInfo();
                    if (!string.IsNullOrEmpty(str2))
                    {
                        string str3 = CFileManager.CombinePath(s_cachedTextureDirectory, str2 + ".bytes");
                        if (CFileManager.IsFileExist(str3))
                        {
                            CFileManager.DeleteFile(str3);
                        }
                    }
                }
                CCachedTextureInfo cachedTextureInfo = new CCachedTextureInfo {
                    m_key            = key,
                    m_width          = width,
                    m_height         = height,
                    m_lastModifyTime = DateTime.Now,
                    m_isGif          = isGif
                };
                this.m_cachedTextureInfoSet.AddTextureInfo(key, cachedTextureInfo);
            }
            this.m_cachedTextureInfoSet.SortTextureInfo();
            int offset = 0;

            this.m_cachedTextureInfoSet.Write(s_buffer, ref offset);
            if (CFileManager.IsFileExist(s_cachedTextureInfoSetFileFullPath))
            {
                CFileManager.DeleteFile(s_cachedTextureInfoSetFileFullPath);
            }
            CFileManager.WriteFile(s_cachedTextureInfoSetFileFullPath, s_buffer, 0, offset);
            string filePath = CFileManager.CombinePath(s_cachedTextureDirectory, key + ".bytes");

            if (CFileManager.IsFileExist(filePath))
            {
                CFileManager.DeleteFile(filePath);
            }
            CFileManager.WriteFile(filePath, data);
        }
예제 #15
0
    public void RemoveFile(string key)
    {
        string cachedFileFullPath = CFileManager.CombinePath(m_dir, key + m_fileExtension);

        if (CFileManager.IsFileExist(cachedFileFullPath))
        {
            CFileManager.DeleteFile(cachedFileFullPath);
        }

        m_cachedFileInfoSet.RemoveFileInfo(key);
    }
예제 #16
0
        public void AddCachedTexture(string url, int width, int height, bool isGif, byte[] data)
        {
            string md = CFileManager.GetMd5(url.ToLower());

            if (this.m_cachedTextureInfoSet.m_cachedTextureInfoMap.ContainsKey(md))
            {
                CCachedTextureInfo cCachedTextureInfo = null;
                this.m_cachedTextureInfoSet.m_cachedTextureInfoMap.TryGetValue(md, ref cCachedTextureInfo);
                DebugHelper.Assert(this.m_cachedTextureInfoSet.m_cachedTextureInfos.Contains(cCachedTextureInfo), "zen me ke neng?");
                cCachedTextureInfo.m_width          = width;
                cCachedTextureInfo.m_height         = height;
                cCachedTextureInfo.m_lastModifyTime = DateTime.get_Now();
                cCachedTextureInfo.m_isGif          = isGif;
            }
            else
            {
                if (this.m_cachedTextureInfoSet.m_cachedTextureInfos.get_Count() >= 100)
                {
                    string text = this.m_cachedTextureInfoSet.RemoveEarliestTextureInfo();
                    if (!string.IsNullOrEmpty(text))
                    {
                        string text2 = CFileManager.CombinePath(CCachedTextureManager.s_cachedTextureDirectory, text + ".bytes");
                        if (CFileManager.IsFileExist(text2))
                        {
                            CFileManager.DeleteFile(text2);
                        }
                    }
                }
                CCachedTextureInfo cCachedTextureInfo2 = new CCachedTextureInfo();
                cCachedTextureInfo2.m_key            = md;
                cCachedTextureInfo2.m_width          = width;
                cCachedTextureInfo2.m_height         = height;
                cCachedTextureInfo2.m_lastModifyTime = DateTime.get_Now();
                cCachedTextureInfo2.m_isGif          = isGif;
                this.m_cachedTextureInfoSet.AddTextureInfo(md, cCachedTextureInfo2);
            }
            this.m_cachedTextureInfoSet.SortTextureInfo();
            int num = 0;

            this.m_cachedTextureInfoSet.Write(CCachedTextureManager.s_buffer, ref num);
            if (CFileManager.IsFileExist(CCachedTextureManager.s_cachedTextureInfoSetFileFullPath))
            {
                CFileManager.DeleteFile(CCachedTextureManager.s_cachedTextureInfoSetFileFullPath);
            }
            CFileManager.WriteFile(CCachedTextureManager.s_cachedTextureInfoSetFileFullPath, CCachedTextureManager.s_buffer, 0, num);
            string text3 = CFileManager.CombinePath(CCachedTextureManager.s_cachedTextureDirectory, md + ".bytes");

            if (CFileManager.IsFileExist(text3))
            {
                CFileManager.DeleteFile(text3);
            }
            CFileManager.WriteFile(text3, data);
        }
예제 #17
0
 public CCachedTextureManager()
 {
     if (!CFileManager.IsDirectoryExist(s_cachedTextureDirectory))
     {
         CFileManager.CreateDirectory(s_cachedTextureDirectory);
     }
     if (CFileManager.IsFileExist(s_cachedTextureInfoSetFileFullPath))
     {
         byte[] data   = CFileManager.ReadFile(s_cachedTextureInfoSetFileFullPath);
         int    offset = 0;
         this.m_cachedTextureInfoSet.Read(data, ref offset);
     }
 }
예제 #18
0
 public CCachedTextureManager()
 {
     this.m_cachedTextureInfoSet = new CCachedTextureInfoSet();
     if (!CFileManager.IsDirectoryExist(CCachedTextureManager.s_cachedTextureDirectory))
     {
         CFileManager.CreateDirectory(CCachedTextureManager.s_cachedTextureDirectory);
     }
     if (CFileManager.IsFileExist(CCachedTextureManager.s_cachedTextureInfoSetFileFullPath))
     {
         byte[] data = CFileManager.ReadFile(CCachedTextureManager.s_cachedTextureInfoSetFileFullPath);
         int    num  = 0;
         this.m_cachedTextureInfoSet.Read(data, ref num);
     }
 }
예제 #19
0
    public static byte[] ReadFile(string filePath)
    {
        if (!CFileManager.IsFileExist(filePath))
        {
            return(null);
        }
        byte[] array = null;
        int    num   = 0;

        do
        {
            try
            {
                array = File.ReadAllBytes(filePath);
            }
            catch (Exception ex)
            {
                Debug.Log(string.Concat(new object[]
                {
                    "Read File ",
                    filePath,
                    " Error! Exception = ",
                    ex.ToString(),
                    ", TryCount = ",
                    num
                }));
                array = null;
            }
            if (array != null && array.Length > 0)
            {
                return(array);
            }
            num++;
        }while (num < 3);
        Debug.Log(string.Concat(new object[]
        {
            "Read File ",
            filePath,
            " Fail!, TryCount = ",
            num
        }));
        CFileManager.s_delegateOnOperateFileFail(filePath, enFileOperation.ReadFile);
        return(null);
    }
예제 #20
0
    public void LoadResourcePackerInfoSet()
    {
        if (this.m_resourcePackerInfoSet != null)
        {
            this.m_resourcePackerInfoSet.Dispose();
            this.m_resourcePackerInfoSet = null;
        }
        string filePath = CFileManager.CombinePath(CFileManager.GetIFSExtractPath(), CResourcePackerInfoSet.s_resourcePackerInfoSetFileName);

        if (CFileManager.IsFileExist(filePath))
        {
            byte[] data = CFileManager.ReadFile(filePath);
            int    num  = 0;
            this.m_resourcePackerInfoSet = new CResourcePackerInfoSet();
            this.m_resourcePackerInfoSet.Read(data, ref num);
            CVersion.SetUsedResourceVersion(this.m_resourcePackerInfoSet.m_version);
            this.m_resourcePackerInfoSet.CreateResourceMap();
        }
    }
예제 #21
0
    //--------------------------------------------------
    /// 获取缓存的资源文件路径
    /// @url        : 地址
    /// @validDays  : 有效天数
    //--------------------------------------------------
    public string GetCachedFilePath(string url, float validDays)
    {
        string key = CFileManager.GetMd5(url.ToLower());

        CCachedFileInfo cachedFileInfo = m_cachedFileInfoSet.GetFileInfo(key);

        //不存在
        if (cachedFileInfo == null)
        {
            return(string.Empty);
        }

        //检查是否过期
        if ((DateTime.Now - cachedFileInfo.m_lastModifyTime).TotalDays >= validDays)
        {
            RemoveFile(key);
            return(string.Empty);
        }

        string cachedFileFullPath = CFileManager.CombinePath(m_dir, key + m_fileExtension);

        //检查文件是否存在
        if (CFileManager.IsFileExist(cachedFileFullPath))
        {
            //通过校验文件长度,来判断是否被串改
            if (cachedFileInfo.m_fileLength == (int)CFileManager.GetFileLength(cachedFileFullPath))
            {
                return(cachedFileFullPath);
            }
            else
            {
                RemoveFile(key);
            }
        }

        return(string.Empty);
    }
예제 #22
0
        public Texture2D GetCachedTexture(string url, float validDays)
        {
            string             md = CFileManager.GetMd5(url.ToLower());
            CCachedTextureInfo cachedTextureInfo = this.m_cachedTextureInfoSet.GetCachedTextureInfo(md);

            if (cachedTextureInfo == null || (DateTime.get_Now() - cachedTextureInfo.m_lastModifyTime).get_TotalDays() >= (double)validDays)
            {
                return(null);
            }
            string text = CFileManager.CombinePath(CCachedTextureManager.s_cachedTextureDirectory, md + ".bytes");

            if (!CFileManager.IsFileExist(text))
            {
                return(null);
            }
            byte[] array = CFileManager.ReadFile(text);
            if (array == null || array.Length <= 0)
            {
                return(null);
            }
            Texture2D texture2D = null;

            if (cachedTextureInfo.m_isGif)
            {
                using (MemoryStream memoryStream = new MemoryStream(array))
                {
                    texture2D = GifHelper.GifToTexture(memoryStream, 0);
                }
            }
            else
            {
                texture2D = new Texture2D(cachedTextureInfo.m_width, cachedTextureInfo.m_height, TextureFormat.ARGB32, false);
                texture2D.LoadImage(array);
            }
            return(texture2D);
        }
예제 #23
0
    //--------------------------------------------------
    /// 添加缓存文件
    /// @url
    /// @cacheType
    /// @width
    /// @height
    /// @isGif
    /// @data
    //--------------------------------------------------
    public void AddFile(string url, byte[] data, int tagInt1 = 0, int tagInt2 = 0, bool tagBool = false)
    {
        string key = CFileManager.GetMd5(url.ToLower());
        List <CCachedFileInfo> cachedFileInfoList = m_cachedFileInfoSet.m_cachedFileInfos;

        if (cachedFileInfoList == null)
        {
            return;
        }

        if (m_cachedFileInfoSet.m_cachedFileInfoMap.ContainsKey(key))
        {
            CCachedFileInfo cachedFileInfo = null;
            m_cachedFileInfoSet.m_cachedFileInfoMap.TryGetValue(key, out cachedFileInfo);

            Debug.Assert(cachedFileInfoList != null && cachedFileInfoList.Contains(cachedFileInfo), "zen me ke neng?");

            //修改信息
            cachedFileInfo.m_fileLength     = data.Length;
            cachedFileInfo.m_lastModifyTime = DateTime.Now;
            cachedFileInfo.m_tagInt1        = tagInt1;
            cachedFileInfo.m_tagInt2        = tagInt2;
            cachedFileInfo.m_tagBool        = tagBool;
        }
        else
        {
            //如果数量达到上限,移除排在最前面的文件
            if (cachedFileInfoList.Count >= m_maxCnt)
            {
                string removeKey = m_cachedFileInfoSet.RemoveEarliestFileInfo();

                //删除缓存文件
                if (!string.IsNullOrEmpty(removeKey))
                {
                    string removeCachedFileFullPath = CFileManager.CombinePath(m_dir, removeKey + m_fileExtension);
                    if (CFileManager.IsFileExist(removeCachedFileFullPath))
                    {
                        CFileManager.DeleteFile(removeCachedFileFullPath);
                    }
                }
            }

            CCachedFileInfo cachedFileInfo = new CCachedFileInfo();
            cachedFileInfo.m_key            = key;
            cachedFileInfo.m_fileLength     = data.Length;
            cachedFileInfo.m_lastModifyTime = DateTime.Now;
            cachedFileInfo.m_tagInt1        = tagInt1;
            cachedFileInfo.m_tagInt2        = tagInt2;
            cachedFileInfo.m_tagBool        = tagBool;

            m_cachedFileInfoSet.AddFileInfo(key, cachedFileInfo);
        }

        //排序
        m_cachedFileInfoSet.m_cachedFileInfos.Sort();

        //写入信息文件
        byte[] buffer = CFileManager.LockFileBuffer();
        try
        {
            MakeDirReady();
            int offset = 0;
            m_cachedFileInfoSet.Write(buffer, ref offset);

            if (CFileManager.IsFileExist(m_metaFilePath))
            {
                CFileManager.DeleteFile(m_metaFilePath);
            }

            CFileManager.WriteFile(m_metaFilePath, buffer, 0, offset);
        }
        finally
        {
            CFileManager.UnLockFileBuffer();
        }

        //写入数据文件
        string cachedFileFullPath = CFileManager.CombinePath(m_dir, key + m_fileExtension);

        if (CFileManager.IsFileExist(cachedFileFullPath))
        {
            CFileManager.DeleteFile(cachedFileFullPath);
        }

        CFileManager.WriteFile(cachedFileFullPath, data);
    }
예제 #24
0
    public void LoadAssetBundle(string ifsExtractPath)
    {
        if (this.m_isAssetBundle)
        {
            if (this.dependency != null && this.dependency.m_isAssetBundle && !this.dependency.IsAssetBundleLoaded())
            {
                this.dependency.LoadAssetBundle(ifsExtractPath);
            }
            if (this.m_assetBundleState != enAssetBundleState.Unload)
            {
                return;
            }
            this.m_useASyncLoadingData = false;
            string text = CFileManager.CombinePath(ifsExtractPath, this.m_pathInIFS);
            if (CFileManager.IsFileExist(text))
            {
                if (this.IsUnCompress())
                {
                    int num = 0;
                    while (true)
                    {
                        try
                        {
                            this.m_assetBundle = AssetBundle.CreateFromFile(text);
                        }
                        catch (Exception)
                        {
                            this.m_assetBundle = null;
                        }
                        if (this.m_assetBundle != null)
                        {
                            break;
                        }
                        Debug.Log(string.Concat(new object[]
                        {
                            "Create AssetBundle ",
                            text,
                            " From File Error! Try Count = ",
                            num
                        }));
                        num++;
                        if (num >= 3)
                        {
                            goto Block_10;
                        }
                    }
                    goto IL_FC;
Block_10:
                    CFileManager.s_delegateOnOperateFileFail(text, enFileOperation.ReadFile);
                    IL_FC :;
                }
                else
                {
                    this.m_assetBundle = AssetBundle.CreateFromMemoryImmediate(CFileManager.ReadFile(text));
                }
                if (this.m_assetBundle == null)
                {
                    string text2 = string.Empty;
                    try
                    {
                        text2 = CFileManager.GetFileMd5(text);
                    }
                    catch (Exception)
                    {
                        text2 = string.Empty;
                    }
                    string message = string.Format("Load AssetBundle {0} Error!!! App version = {1}, Build = {2}, Reversion = {3}, Resource version = {4}, File md5 = {5}", new object[]
                    {
                        text,
                        CVersion.GetAppVersion(),
                        CVersion.GetBuildNumber(),
                        CVersion.GetRevisonNumber(),
                        CVersion.GetUsedResourceVersion(),
                        text2
                    });
                    Debug.Log(message);
                }
            }
            else
            {
                Debug.Log("File " + text + " can not be found!!!");
            }
            this.m_assetBundleState = enAssetBundleState.Loaded;
        }
    }