using System.Collections; 
 | 
using System.Collections.Generic; 
 | 
using UnityEngine; 
 | 
using System.IO; 
 | 
  
 | 
public class SevenZipUtility 
 | 
{ 
 | 
    static string m_SevenZipToolPath = string.Empty; 
 | 
    static string sevenZipToolPath { 
 | 
        get { 
 | 
            if (string.IsNullOrEmpty(m_SevenZipToolPath)) 
 | 
            { 
 | 
                if (Directory.Exists("C:/Program Files/7-Zip")) 
 | 
                { 
 | 
                    m_SevenZipToolPath = "C:/Program Files/7-Zip"; 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    m_SevenZipToolPath = "C:/Program Files (x86)/7-Zip"; 
 | 
                } 
 | 
            } 
 | 
  
 | 
            return m_SevenZipToolPath; 
 | 
        } 
 | 
    } 
 | 
  
 | 
    public static void Compress(string from, string to) 
 | 
    { 
 | 
        if (File.Exists(to)) 
 | 
        { 
 | 
            File.Delete(to); 
 | 
        } 
 | 
  
 | 
        var cmd = string.Format("\"{0}\\7z\" a {1} {2} -mx9", sevenZipToolPath, to, from); 
 | 
        SystemCMD.RunCmd(cmd); 
 | 
    } 
 | 
  
 | 
    public static CompressProgress CompressStreamingAssets() 
 | 
    { 
 | 
        var files = new List<FileInfo>(); 
 | 
        FileExtersion.GetAllDirectoryFileInfos(Application.streamingAssetsPath, files); 
 | 
  
 | 
        var progress = new CompressProgress(); 
 | 
        progress.total = files.Count; 
 | 
  
 | 
        foreach (var item in files) 
 | 
        { 
 | 
            var fullName = item.FullName; 
 | 
            var extension = Path.GetExtension(item.FullName); 
 | 
            if (extension == ".meta") 
 | 
            { 
 | 
                continue; 
 | 
            } 
 | 
  
 | 
            var to = string.Empty; 
 | 
            if (string.IsNullOrEmpty(extension)) 
 | 
            { 
 | 
                to = fullName + ".7z"; 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                to = fullName.Replace(extension, ".7z"); 
 | 
            } 
 | 
  
 | 
            Compress(fullName, to); 
 | 
            progress.complete++; 
 | 
        } 
 | 
  
 | 
        return progress; 
 | 
    } 
 | 
  
 | 
    public class CompressProgress 
 | 
    { 
 | 
        public int total; 
 | 
        public int complete; 
 | 
        public float progress { 
 | 
            get { 
 | 
                return complete / (float)total; 
 | 
            } 
 | 
        } 
 | 
  
 | 
        public bool done { 
 | 
            get { 
 | 
                return complete >= total; 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
} 
 |