示例#1
0
    private static void SaveToFile(Dictionary <string, Dictionary <string, FileMD5Item> > DicFileInfo)
    {
        string savePath = EditorTools.mExportVersionFolderLocationFloder;

        if (!Directory.Exists(savePath))
        {
            Directory.CreateDirectory(savePath);
        }
        string curPath = EditorTools.mExportVersionFolderLocationFloder + "/" + EditorTools.mExportVersionFolderName;

        PrefabInfo oldInfo = IO.LoadFromFile <PrefabInfo>(curPath);

        if (oldInfo != null)
        {
            foreach (PrefabCol col in oldInfo.Files)
            {
                Dictionary <string, FileMD5Item> DicFileMD5 = new Dictionary <string, FileMD5Item>();
                foreach (FileMD5Item item in col.FileInfo)
                {
                    if (!DicFileMD5.ContainsKey(item.FileName))
                    {
                        FileMD5Item data = new FileMD5Item(item.FileName, item.MD5, item.Size);
                        DicFileMD5.Add(item.FileName, data);
                    }
                }
                if (!DicFileInfo.ContainsKey(col.FileName))
                {
                    DicFileInfo.Add(col.FileName, DicFileMD5);
                }
                else
                {
                    DicFileInfo[col.FileName] = DicFileMD5;
                }
            }
        }

        if (File.Exists(curPath))
        {
            File.Delete(curPath);
        }

        PrefabInfo prefabinfo = new PrefabInfo();

        foreach (KeyValuePair <string, Dictionary <string, FileMD5Item> > info in DicFileInfo)
        {
            PrefabCol prefabcol = new PrefabCol(info.Key);
            foreach (KeyValuePair <string, FileMD5Item> pair in info.Value)
            {
                FileMD5Item item = new FileMD5Item(pair.Value.FileName, pair.Value.MD5, pair.Value.Size);
                prefabcol.addItem(item);
            }
            prefabcol.End();
            prefabinfo.addItem(prefabcol);
        }
        prefabinfo.End();
        IO.SaveToFile(prefabinfo, curPath);
    }