少年修仙传客户端基础资源
liuxue
2021-08-12 6149631752ee76f85e8eca17454ddaf27fc13dbc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using Debug = UnityEngine.Debug;
 
 
public class FileTool
{
    public static bool CheckFolder(string path){
        if (Directory.Exists(path)) {
            return true;
        }
        UnityEditor.EditorUtility.DisplayDialog("Error", "Path does not exist \n\t" + path, "确认");
        return false;
    }
    public static void OpenFolder(string path){
        if (CheckFolder(path)) {
            System.Diagnostics.Process.Start( path);
        }
        
    }
    
    public static void CopyFolder(Dictionary<string, string> copyDic){
        foreach (KeyValuePair<string, string> path in copyDic) {
 
            if (CheckFolder(path.Key)) {
                
                CopyDir(path.Key, path.Value);
                Debug.Log("Copy Success : \n\tFrom:" + path.Key + " \n\tTo:" + path.Value);
            }
        }
        EditorUtility.ClearProgressBar();
    }
 
    public static void CopyFolder(string fromPath, string toPath){
        CopyDir(fromPath, toPath);
        Debug.Log("Copy Success : \n\tFrom:" + fromPath + " \n\tTo:" + toPath);
        EditorUtility.ClearProgressBar();
    }
       
    public static void CreateFolder(string path){
        if (Directory.Exists(path)) {
            Directory.Delete(path, true);
        }
        Directory.CreateDirectory(path);
    }
 
    public static void DeleteFolder(string path){
        if (Directory.Exists(path)) {
            Directory.Delete(path, true);
        }
    }
 
    private static void CopyDir(string origin, string target){
#if UNITY_IOS
      
        if (!origin.EndsWith("/"))
        {
            origin += "/";
        }
 
        if (!target.EndsWith("/"))
        {
            target += "/";
        }
#else
          if (!origin.EndsWith("\\")) {
            origin += "\\";
        }
 
        if (!target.EndsWith("\\")) {
            target += "\\";
        }
 
#endif
        if (!Directory.Exists(target)) {
            Directory.CreateDirectory(target);
        }
    
        DirectoryInfo info = new DirectoryInfo(origin);
        FileInfo[] fileList = info.GetFiles();
        DirectoryInfo[] dirList = info.GetDirectories();
        float index = 0;
        foreach (FileInfo fi in fileList) {
            
 
            if (fi.Extension == ".zip" || fi.Extension == ".meta"|| fi.Extension == ".rar") {
                Debug.Log("dont copy :"+fi.FullName);
                continue;
            }
            float progress = (index / (float)fileList.Length); 
            EditorUtility.DisplayProgressBar("Copy ", "Copying: "+Path.GetFileName(fi.FullName),progress);
            File.Copy(fi.FullName, target + fi.Name, true);
            index++;
        }
 
        foreach (DirectoryInfo di in dirList) {
            if (di.FullName.Contains(".svn")) {
                Debug.Log("Continue SVN "+di.FullName);
                continue;
            }
 
            CopyDir(di.FullName, target + "\\" + di.Name);
        }
    }
}