Ejemplo n.º 1
0
    // 유틸 : 파일로 부터 정보얻어서 테이블 데이터 객체만들기
    SHResourcesInfo MakeResourceInfo(FileInfo pFile)
    {
        // 예외처리 : 리스팅에서 제외할 파일
        if (true == CheckExceptionFile(pFile))
        {
            return(null);
        }

        // 알리아싱
        string strRoot      = "Resources";
        string strFullName  = pFile.FullName.Substring(pFile.FullName.IndexOf(strRoot) + strRoot.Length + 1).Replace("\\", "/");
        string strExtension = Path.GetExtension(strFullName);

        // 기록
        var pInfo = new SHResourcesInfo();

        pInfo.m_strName      = Path.GetFileNameWithoutExtension(strFullName);
        pInfo.m_strFileName  = Path.GetFileName(strFullName);
        pInfo.m_strExtension = strExtension;
        pInfo.m_strSize      = pFile.Length.ToString();
        pInfo.m_strHash      = SHHash.GetMD5ToFile(pFile.FullName);
        pInfo.m_strPath      = strFullName.Substring(0, strFullName.Length - strExtension.Length);

        return(pInfo);
    }
Ejemplo n.º 2
0
    public static string Md5(string strEncrypt)
    {
        var pEncoder   = new UTF8Encoding();
        var pHashBytes = SHHash.GetMD5ToBuff(pEncoder.GetBytes(strEncrypt));

        string strHash = string.Empty;

        for (int iLoop = 0; iLoop < pHashBytes.Length; ++iLoop)
        {
            strHash += Convert.ToString(pHashBytes[iLoop], 16).PadLeft(2, '0');
        }
        return(strHash.PadLeft(32, '0'));
    }
Ejemplo n.º 3
0
    public override bool?LoadJsonTable(JSONNode pJson, string strFileName)
    {
        if (null == pJson)
        {
            return(false);
        }

        int iMaxTable = pJson["AssetBundleInfo"].Count;

        for (int iLoop = 0; iLoop < iMaxTable; ++iLoop)
        {
            JSONNode        pDataNode = pJson["AssetBundleInfo"][iLoop];
            AssetBundleInfo pData     = new AssetBundleInfo();
            pData.m_strBundleName = GetStrToJson(pDataNode, "s_BundleName");
            pData.m_lBundleSize   = (long)GetIntToJson(pDataNode, "s_BundleSize");
            pData.m_pHash128      = SHHash.GetHash128(GetStrToJson(pDataNode, "s_BundleHash"));

            int iMaxUnit = pDataNode["p_Resources"].Count;
            for (int iLoopUnit = 0; iLoopUnit < iMaxUnit; ++iLoopUnit)
            {
                JSONNode             pUnitNode = pDataNode["p_Resources"][iLoopUnit];
                SHResourcesTableInfo pUnit     = new SHResourcesTableInfo();
                pUnit.m_strName      = GetStrToJson(pUnitNode, "s_Name");
                pUnit.m_strFileName  = GetStrToJson(pUnitNode, "s_FileName");
                pUnit.m_strExtension = GetStrToJson(pUnitNode, "s_Extension");
                pUnit.m_strSize      = GetStrToJson(pUnitNode, "s_Size");
                //pUnit.m_strLastWriteTime    = GetStrToJson(pUnitNode, "s_LastWriteTime");
                pUnit.m_strHash       = GetStrToJson(pUnitNode, "s_Hash");
                pUnit.m_strPath       = GetStrToJson(pUnitNode, "s_Path");
                pUnit.m_eResourceType = SHHard.GetResourceTypeToExtension(pUnit.m_strExtension);

                pData.AddResourceInfo(pUnit);
            }

            AddData(pData.m_strBundleName, pData);
        }

        return(true);
    }
Ejemplo n.º 4
0
    // 인터페이스 : 번들정보 업데이트( Streaming기준으로 추가/변경/제거된 번들목록을 갱신한다. )
    public Dictionary <string, AssetBundleInfo> UpdateAssetBundlesMakeInfoByStreamingPath(string strCDN, BuildTarget eTarget)
    {
        // Download 경로
        var strDownloadPath = string.Format("{0}/{1}/{2}.json", strCDN, SHHard.GetStrToPlatform(eTarget), m_strFileName);

        // CDN에 있는 AssetBundleInfo.Json 다운로드
        var pCDNInfo = new JsonAssetBundleInfo();

        pCDNInfo.LoadJsonTable((new SHJson()).LoadWWW(strDownloadPath), m_strFileName);

        // 로컬 Streaming에 저장된 AssetBundleInfo 로드
        var pStreamingInfo = new JsonAssetBundleInfo();

        pStreamingInfo.LoadJsonTable((new SHJson()).LoadToStreamingForLocal(m_strFileName), m_strFileName);

        // StreamingPath기준으로 목록 갱신
        SHUtils.ForToDic(pStreamingInfo.GetContainer(), (pStreamingKey, pStreamingValue) =>
        {
            var pCDNBundleInfo = pCDNInfo.GetBundleInfo(pStreamingKey);

            // 추가 : 번들자체가 CDN에는 없고, Streaming에는 있는 경우
            if (null == pCDNBundleInfo)
            {
                pStreamingValue.m_lBundleSize = 0;
                pStreamingValue.m_pHash128    = SHHash.GetHash128("0");
                return;
            }

            // 변경 : 번들자체가 CDN과 Streaming이 다르다면 비교할 수 있게 CDN내용을 복사
            pStreamingValue.m_lBundleSize = pCDNBundleInfo.m_lBundleSize;
            pStreamingValue.m_pHash128    = pCDNBundleInfo.m_pHash128;

            // 리소스 업데이트 체크
            SHUtils.ForToDic(pStreamingValue.m_dicResources, (pResKey, pResValue) =>
            {
                var pCDNResInfo = pCDNBundleInfo.GetResourceInfo(pStreamingKey);

                // 추가 : 리소스가 CDN에는 없고, Streaming에는 있는 경우
                if (null == pCDNResInfo)
                {
                    pResValue.m_strSize = "0";
                    pResValue.m_strHash = "0";
                }
                // 변경 : 리소스가 CDN과 Streaming이 다르다면 비교할 수 있게 CDN내용을 복사
                else
                {
                    pResValue.CopyTo(pCDNResInfo);
                }
            });

            // 추가 : 리소스가 CDN에는 있고, Streaming 에는 없는 경우 비교할 수 있게 CDN내용 추가
            SHUtils.ForToDic(pCDNBundleInfo.m_dicResources, (pResKey, pResValue) =>
            {
                if (true == pStreamingValue.IsIncludeResource(pResKey))
                {
                    return;
                }

                pStreamingValue.AddResourceInfo(pResValue);
            });
        });

        return(pStreamingInfo.GetContainer());
    }