Esempio n. 1
0
        private static void AddIdxFileToChecksum(ref Dictionary <string, BundleCheckSumData> checksumDict, string idxPath, string fileName)
        {
            string             dp          = PackRes_Common.GetOrCreateAbsPath(idxPath);
            string             dstFile     = Path.Combine(dp, fileName.Trim(PackRes_Def.trim));
            BundleCheckSumData idxChecksum = new BundleCheckSumData();

            idxChecksum.md5  = PackRes_Common.ComputeFileMD5Value(dstFile);
            idxChecksum.size = PackRes_Common.GetFileSize(dstFile);
            checksumDict.Add(fileName, idxChecksum);
        }
Esempio n. 2
0
        private static void GenerateIndexFile()
        {
            PackRes_Def.PackSetting textureSetting = PackRes_Textures.packSetting;
            PackRes_Def.PackSetting guiSetting     = PackRes_Gui.packSetting;
            PackRes_Def.PackSetting sceneSetting   = PackRes_Scene.packSetting;



            List <PackRes_Def.PackSetting> packSettingList = new List <PackRes_Def.PackSetting>();

            packSettingList.Add(textureSetting);
            packSettingList.Add(guiSetting);
            packSettingList.Add(sceneSetting);

            string platformDir = Path.Combine(Path.GetFullPath(binPath), platform);

            if (Directory.Exists(platformDir))
            {
                Directory.Delete(Path.Combine(Path.GetFullPath(binPath), platform), true);
            }
            Directory.CreateDirectory(Path.Combine(Path.GetFullPath(binPath), platform));

            Dictionary <string, BundleCheckSumData> bundleChecksumDict = new Dictionary <string, BundleCheckSumData>();
            Dictionary <string, string>             idxMap             = new Dictionary <string, string>();

            foreach (PackRes_Def.PackSetting packSetting in packSettingList)
            {
                string idxfile = packSetting.GetPlatformIdxFileFullPath(platform);
                idxfile = Path.Combine(idxfile, packSetting.index_file);

                string srcBundlePath  = packSetting.GetPlatformBundleFullPath(platform);
                string destBundlePath = Path.Combine(Path.GetFullPath(binPath), platform);

                Debug.Log("idxfile: " + idxfile);

                Dictionary <string, string> tempIdx = LoadIdxMapFile(idxfile);
                foreach (KeyValuePair <string, string> pair in tempIdx)
                {
                    if (idxMap.ContainsKey(pair.Key))
                    {
                        Debug.LogError("Dupilate asset : " + pair.Key + "  bundle: " + pair.Value);
                        throw new PackRes_Def.PckException("Dupilate asset : " + pair.Key + "  bundle: " + pair.Value);
                    }
                    else
                    {
                        idxMap.Add(pair.Key, pair.Value);

                        //copy the bundle file to bin path
                        string srcfile  = Path.Combine(srcBundlePath, pair.Value);
                        string destfile = Path.Combine(destBundlePath, pair.Value);
                        if (!File.Exists(srcfile))
                        {
                            Debug.LogError("srcfile not exist: " + srcfile);
                            throw new PackRes_Def.PckException("srcfile not exist: " + srcfile);
                        }
                        if (!File.Exists(destfile))
                        {
                            File.Copy(srcfile, destfile);
                        }

                        //create the bundleMD5Dict
                        if (!bundleChecksumDict.ContainsKey(pair.Value))
                        {
                            BundleCheckSumData checksum = new BundleCheckSumData();
                            checksum.md5  = PackRes_Common.ComputeFileMD5Value(destfile);
                            checksum.size = PackRes_Common.GetFileSize(destfile);
                            bundleChecksumDict.Add(pair.Value, checksum);
                        }
                    }
                }
            }
            string temppath = Path.Combine(binPath, platform);

            PackRes_Common.ExpIdxFile(temppath, idxMap, idxFileName);
            AddIdxFileToChecksum(ref bundleChecksumDict, temppath, idxFileName);
            PackRes_Common.ExpBundleCheckSumFile(temppath, bundleChecksumDict, bundleMd5FileName);
        }