Created
March 17, 2017 09:01
-
-
Save sunny352/2ba8331644fd8dfeacbdbaae119c61ab to your computer and use it in GitHub Desktop.
Zip压缩,需要UniRx和SharpZipLib支持
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using ICSharpCode.SharpZipLib.Zip; | |
using System.Collections; | |
using UniRx; | |
using UnityEngine; | |
public static class ZipUtil | |
{ | |
public static IEnumerator Create(string name) | |
{ | |
string pakPath = string.Format("{0}/{1}.pak", Application.temporaryCachePath, name); | |
string srcPath = string.Format("{0}/{1}", Application.persistentDataPath, name); | |
return Observable.Start(() => | |
{ | |
FastZip fastZip = new FastZip(); | |
fastZip.CreateZip(pakPath, srcPath, true, null); | |
return Unit.Default; | |
}).ObserveOnMainThread().ToYieldInstruction(); | |
} | |
public static IEnumerator Extract(string name) | |
{ | |
string pakPath = string.Format("{0}/{1}.pak", Application.temporaryCachePath, name); | |
string srcPath = string.Format("{0}/{1}", Application.persistentDataPath, name); | |
return Observable.Start(() => | |
{ | |
FastZip fastZip = new FastZip(); | |
fastZip.ExtractZip(pakPath, srcPath, string.Empty); | |
return Unit.Default; | |
}).ObserveOnMainThread().ToYieldInstruction(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment