using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BirdyFlash.Lib { public class DeviceE2PContents { public DeviceInfo deviceInfo; public List data; public DeviceE2PContents() { } public bool writeAsFile(E2PFileFormat fileFormat, string filePath) { if (fileFormat == E2PFileFormat.Binary) { System.IO.File.WriteAllBytes(filePath, this.data.ToArray()); return true; } if (fileFormat == E2PFileFormat.HEXText) { string hexText = string.Join("\n", BitConverter.ToString(this.data.ToArray()).Replace('-',' ').Split(3*32) ); System.IO.File.WriteAllBytes(filePath, Encoding.ASCII.GetBytes(hexText)); return true; } return false; } public static string getFileExtension(DeviceInfo deviceInfo) { return deviceInfo.model[0].ToString().ToLower() + deviceInfo.model.ToString().Substring(1) + ".rev2"; } public void readFromFile(E2PFileFormat fileFormat, string filePath) { if (fileFormat == E2PFileFormat.Binary) { this.data = new List(System.IO.File.ReadAllBytes(filePath)); return; } } } public enum E2PFileFormat { TPLOriginal = 0, Binary = 1, HEXText = 2 } }