using System; using System.Collections.Generic; using System.IO; using UnityEngine; namespace Inno.DLC { public class DLCFile { public DLCFile(string id, Dictionary values) { this._identifier = id; this._name = values["Name"]; this._url = values["URL"]; this._checksum = long.Parse(values["Checksum"]); this._bytes = long.Parse(values["Bytes"]); this._properties = values; } public string Identifier { get { return this._identifier; } } public string Name { get { return this._name; } } public bool Exists { get { return File.Exists(this.AbsolutePath); } } public long Bytes { get { return this._bytes; } } public byte[] GetContents() { return File.ReadAllBytes(this.AbsolutePath); } public bool Check() { string absolutePath = this.AbsolutePath; if (!File.Exists(absolutePath)) { UnityEngine.Debug.LogWarning("Exists"); return false; } FileInfo fileInfo = new FileInfo(absolutePath); if (fileInfo.Length != this._bytes) { UnityEngine.Debug.LogWarning("Length"); return false; } byte[] contents = this.GetContents(); long num = 0L; foreach (byte b in contents) { num *= 31L; num += (long)b; } if (num != this._checksum) { UnityEngine.Debug.LogWarning("Checksum"); return false; } return true; } public void Delete() { string absolutePath = this.AbsolutePath; if (File.Exists(absolutePath)) { File.Delete(absolutePath); } } public DLCDownloadTask Download() { return new DLCDownloadTask(this._url, this.AbsolutePath); } public string GetProperty(string key) { return this._properties[key]; } public string URI { get { return "file://" + this.AbsolutePath; } } private string AbsolutePath { get { return DLCManager.AbsolutePath(this._name); } } private const string NameKey = "Name"; private const string URLKey = "URL"; private const string ChecksumKey = "Checksum"; private const string BytesKey = "Bytes"; private string _identifier; private string _name; private string _url; private long _checksum; private long _bytes; private Dictionary _properties; } }