static void UploadToServer()
    {
        string serverPath = "D:\\wamp\\www\\SuperWings\\main\\" + AppV + "\\" + CodeV;
        string ResPath    = serverPath + "\\" + ResV;

        if (FileTools.IsDirectoryExist(ResPath))
        {
            EditorUtility.DisplayDialog("提示", "资源版本" + AppV + "." + CodeV + "." + ResV + "已经存在!", "确定");
            return;
        }
        FileTools.CreateDirectory(ResPath);

        string       info     = File.ReadAllText(Path.Combine(AssetOutPath, ResInfoName));
        ResourceInfo itemInfo = JsonUtility.FromJson <ResourceInfo> (info);

        BundleNames.Clear();
        for (int i = 0; i < itemInfo.ResList.Count; i++)
        {
            if (itemInfo.ResList [i].IsAsset)
            {
                BundleNames.Add(itemInfo.ResList [i].Name);
            }
            //AddBundleName (itemInfo.ResList [i]);
        }
        ZipFileToServer(ResPath);
        CreateUpdateFile(ResPath, itemInfo);
        FileTools.CopyFile(FileTools.CombinePath(AssetOutPath, ResInfoName), FileTools.CombinePath(serverPath, ResInfoName));

        EditorUtility.DisplayDialog("提示", "上传完成!", "确定");
    }
 private static void PrintExcepitonLog(Exception e)
 {
     if (e.GetType() == typeof(InvalidOperationException))
     {
         LogTools.PrintError("打包失败,文件已损坏");
     }
     else
     {
         LogTools.PrintError(e.GetType().Name + e.Message);
     }
     LogTools.Error(GetDetailsInfo(), e);
     //将失败的文件拷贝至指定目录
     try
     {
         String exceptionFilePath = GlobalConstants.AbsoluteResourcesPath + "/" + FileTools.GetFileName(srcPath);
         if (FileTools.FileExists(exceptionFilePath))
         {
             LogTools.Info("发生异常的文件存在,文件路径为:" + exceptionFilePath);
             if (!FileTools.DirectoryExists(GlobalConstants.ExceptionFBXFolder))
             {
                 FileTools.CreateDirectory(GlobalConstants.ExceptionFBXFolder);
             }
             String destFilePath = GlobalConstants.ExceptionFBXFolder + "/" + FileTools.GetFileName(exceptionFilePath) + "(" + DateTime.Now.ToString("yyyy-MM-dd HH.mm.ss") + ")";
             FileTools.CopyFile(exceptionFilePath, destFilePath);
         }
         else
         {
             LogTools.Info("发生异常的文件不存在,文件路径为");
         }
     }
     catch (Exception ee)
     {
         LogTools.Error(GetDetailsInfo(), ee);
     }
 }
Exemplo n.º 3
0
        private void CopyFile(string sourceFilePath, string targetFilePath)
        {
            var sourceFile = new FileInfo(sourceFilePath);

            if (!sourceFile.Exists)
            {
                Assert.Fail("Source file not found: " + sourceFile);
            }

            var targetFile = new FileInfo(targetFilePath);

            if (targetFile.Exists)
            {
                targetFile.Delete();
            }

            mFileTools.CopyFile(sourceFilePath, targetFilePath, false);

            System.Threading.Thread.Sleep(150);
            mFileTools.CopyFile(sourceFilePath, targetFilePath, true);

            System.Threading.Thread.Sleep(150);

            // Copy the file again, but with overwrite = false
            // This should raise an exception
            bool exceptionRaised;

            try
            {
                mFileTools.CopyFile(sourceFilePath, targetFilePath, false);
                exceptionRaised = false;
            }
            catch (Exception)
            {
                exceptionRaised = true;
            }

            Assert.IsTrue(exceptionRaised, "File copy with overwrite = false did not raise an exception; it should have");
        }
Exemplo n.º 4
0
    static void UploadAsset(string rootName, string name, int codeV, int resV)
    {
        string ResPath = "D:\\Game\\" + name + "\\" + codeV;

        FileTools.CreateDirectory(ResPath);

        ZipAndCopy(ResPath, name);

        string outP = GetOutPath(CreateAssetBundle.AssetPath);
        string resP = Path.Combine(outP, name + CreateAssetBundle.ResInfoName);

        FileTools.CopyFile(resP, FileTools.CombinePath(ResPath, name + CreateAssetBundle.ResInfoName));

        EditorUtility.DisplayDialog("提示", "上传完成!", "确定");
    }
 /// <summary>
 /// 将srcPath上的文件复制到Resources目录下,并且导入资源
 /// </summary>
 /// <param name="srcPath">需要导入的资源的绝对路径</param>
 /// <returns>导入后的资源的路径(相对路径,基于Assets目录)</returns>
 public static string ImportAsset(string srcPath)
 {
     if (string.IsNullOrEmpty(srcPath))
     {
         throw new System.Exception("资源文件路径不能为空");
     }
     if (!FileTools.FileExists(srcPath))
     {
         throw new System.Exception("资源文件不存在");
     }
     FileTools.CopyFile(srcPath, GlobalConstants.AbsoluteResourcesPath + "/" + FileTools.GetFileName(srcPath));
     AssetDatabase.Refresh();
     srcPath = GlobalConstants.RelativelyResourcesPath + "/" + FileTools.GetFileName(srcPath);
     AssetDatabase.ImportAsset(srcPath);
     return(srcPath);
 }