private List <CFLEntry> getCflEntries() { var s = File.Open(_file, FileMode.Open); var bin = new BinaryReader(s); var header = new CFLHeader(bin); var ehb = header.EntryReader(); var e = new List <CFLEntry>(); var currentReadLength = 0; while (header.EntryList.Length != currentReadLength) { var entry = new CFLEntry(ehb, bin); if (header.SupportsHash) { var len = ehb.ReadInt32(); entry.Hash = new string(ehb.ReadChars(len)); } e.Add(entry); currentReadLength += entry.EntrySize; } ehb.Close(); bin.Close(); return(e); }
public Viewer(LibCFL.CFLEntry item) { _item = item; InitializeComponent(); using (var ms = new MemoryStream(item.FileContents)) { if (ms.IsImage()) { ms.Seek(0, 0); PreviewImage.Visibility = Visibility.Visible; PreviewImage.Stretch = System.Windows.Media.Stretch.None; PreviewImage.Source = BitmapFrame.Create(ms, BitmapCreateOptions.IgnoreImageCache, BitmapCacheOption.OnLoad);; } else { ms.Seek(0, 0); sc.Visibility = Visibility.Visible; TextBoxPreview.Text = UTF8.GetString(ms.ToArray()); } } }
public void Add(string name, byte[] data, CFLLoader.CompressionType compression) { /* * if (compression == CFLLoader.CompressionType.LZMA) * throw new NotSupportedException(); */ var entry = new CFLEntry { Name = name, UnpackedSize = data.Length, Compression = compression, FileContents = data }; if (_cFlHeader.SupportsHash) { entry.Hash = Helpers.CalculateMD5Hash(data); } _entries.Add(entry); }