예제 #1
0
    static void VersionsDifferenceZipImp(string oldVersionDir, string newVersionDir)
    {
        oldVersionDir = MyFileUtil.DealFilePathSlash(oldVersionDir);
        newVersionDir = MyFileUtil.DealFilePathSlash(newVersionDir);

        List <string> oldFileList = new List <string>();
        List <string> newFileList = new List <string>();

        MyFileUtil.GetFileList(oldVersionDir, ref oldFileList);
        MyFileUtil.GetFileList(newVersionDir, ref newFileList);

        List <string> modificationFileList = new List <string>();

        foreach (string newFilePath in newFileList)
        {
            int index = oldFileList.IndexOf(newFilePath);
            if (index < 0)
            {
                //添加新的文件
                modificationFileList.Add(newFilePath);
            }
            else
            {
                string oldFilePath = oldFileList[index];
                if (MD5Tool.VerifyFile(newFilePath, oldFilePath) == false)
                {
                    //文件改变
                    modificationFileList.Add(newFilePath);
                }
            }
        }

        //string time = System.DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss");

        string modificationDir = MyFileUtil.GetParentDir(newVersionDir) + "update_tmp";

        MyFileUtil.DeleteDir(modificationDir);
        MyFileUtil.CreateDir(modificationDir);

        foreach (string filePath in modificationFileList)
        {
            string newFilePath = filePath.Replace(newVersionDir, modificationDir);
            MyFileUtil.CopyFile(filePath, newFilePath);
        }

        string zipFilePath = modificationDir + ".zip";

        ZIPTool.CompressDirectory(modificationDir, zipFilePath, 0, false);

        Debug.Log("");
    }
예제 #2
0
    static private void CopyFile(List <string> fileList, string srcDir, string destDir)
    {
        srcDir  = MyFileUtil.DealFilePathSlash(srcDir);
        destDir = MyFileUtil.DealFilePathSlash(destDir);

        if (srcDir.EndsWith("/") == false)
        {
            srcDir = srcDir + "/";
        }

        if (destDir.EndsWith("/") == false)
        {
            destDir = destDir + "/";
        }

        foreach (string filePath in fileList)
        {
            try
            {
                string newFilePath = destDir + filePath.Replace(srcDir, "");
                string dir         = Path.GetDirectoryName(newFilePath);
                if (Directory.Exists(dir) == false)
                {
                    Directory.CreateDirectory(dir);
                }
                File.Copy(filePath, newFilePath, true);
            }
            catch (System.Exception ex)
            {
                Debug.LogException(ex);
            }
        }

#if UNITY_EDITOR
        AssetDatabase.Refresh();
#endif
    }