示例#1
0
    void OnWizardCreate()
    {
        if (source == null)
        {
            CreateWizard();
        }

        string strSource = AssetDatabase.GetAssetPath(source);
        string strTarget = strSource + ".XOR";

        try
        {
            FileStream fs  = File.Open(strSource, FileMode.Open);
            byte []    mem = new byte[fs.Length];
            fs.Read(mem, 0, (int)fs.Length);
            fs.Close();
            EncryptXOR.EncryptXorString(ref mem);
            FileStream fsWrite = File.Create(strTarget);
            fsWrite.Write(mem, 0, mem.Length);
            fsWrite.Close();
        }
        catch (System.Exception exp)
        {
            Debug.Log(exp.Message);
        }
        AssetDatabase.Refresh();
        EditorUtility.DisplayDialog("Tip", "file : " + strTarget + "Created", "OK");
    }
示例#2
0
    void OnWizardCreate()
    {
        string strTarget = System.Enum.GetName(typeof(BuildTarget), Target);

        if (strTarget == null || strTarget == "")
        {
            CreateWizard();
            return;
        }

        if (FileDirectory == null)
        {
            EditorUtility.DisplayDialog("Error", "SceneDirectory Is Empty", "QUIT");
            CreateWizard();
            return;
        }

        try
        {
            List <string> filelist = null;
            if (IgnoreFile != null && IgnoreFile.Length != 0)
            {
                filelist = new List <string>();
                foreach (string str in IgnoreFile)
                {
                    filelist.Add(str);
                }
            }
            List <string> strCompress = new List <string>();

            if (bEntrypt)
            {
                if (!EncryptXOR.EncryptResource(Target, filelist, FileDirectory, strExt, ref strCompress))
                {
                    CreateWizard();
                    return;
                }
            }
            else
            {
                string SavePath   = PlatformMap.GetPlatformPath(Target) + "/" + VersionManager.GetCurVersion(Target) + "/";
                string SelectPath = AssetDatabase.GetAssetPath(FileDirectory);
                foreach (string st in strExt)
                {
                    string [] files = System.IO.Directory.GetFiles(SelectPath, st, System.IO.SearchOption.AllDirectories);
                    foreach (string stPush in files)
                    {
                        if (!strCompress.Contains(stPush))
                        {
                            strCompress.Add(stPush);
                        }
                    }
                }
            }
            //if encrypted delete original file
            CompressForFile.CompressScript(Target, filelist, strCompress, bEntrypt);

            //write force updated
            string ForceTxtSavePath = "";
            try
            {
                ForceTxtSavePath = PlatformMap.GetPlatformPath(Target) + "/" + VersionManager.GetCurVersion(Target) + "/";
            }
            catch (IOException exp)
            {
                EditorUtility.DisplayDialog("Error", exp.Message, "OK");
                return;
            }

            FileStream fsForce = File.Open(ForceTxtSavePath + "ForceUpdate.txt", FileMode.OpenOrCreate);
            fsForce.Seek(0, SeekOrigin.End);
            int i = 0;
            foreach (string file in strCompress)
            {
                string path = file;
                if (path.EndsWith(".XOR"))
                {
                    path = path.Substring(0, path.Length - 4);
                }

                path  = path.Replace("\\", "/");
                path += ".zip";
                byte[] buffer = System.Text.Encoding.UTF8.GetBytes(path);
                fsForce.Write(buffer, 0, buffer.Length);
                fsForce.Write(new byte[] { (byte)'\r', (byte)'\n' }, 0, 2);
            }
            fsForce.Flush();
            fsForce.Close();
        }
        catch (System.Exception exp)
        {
            Debug.Log(exp.Message);
            CreateWizard();
            return;
        }
    }