private static void ReadEntryHierarchy(LifFile lifFile, BinaryReaderEx br) { var rootBlock = ReadBlockHierarchy(br); var hierarchyBlock = br.ReadStruct <LIFFBlock>(); if (hierarchyBlock.BlockType != 5) { throw new IOException("The file is not a valid LIF. Hierarchy block type is not '5'."); } //if (hierarchyBlock.Spacing1 != 0) // Trace.WriteLine($"Unexpected hierarchy block spacing 1 '{hierarchyBlock.Spacing1}'"); //if (hierarchyBlock.Spacing2 != 1) // Trace.WriteLine($"Unexpected hierarchy block spacing 2 '{hierarchyBlock.Spacing2}'"); //if (hierarchyBlock.Spacing3 != 0) // Trace.WriteLine($"Unexpected hierarchy block spacing 3 '{hierarchyBlock.Spacing3}'"); var rootFolderEntry = br.ReadStruct <LIFFFolderEntry>(); if (rootFolderEntry.EntryType != 1) { throw new IOException("The file is not a valid LIF."); } PopulateFolderFileHierarchy(br, lifFile.RootFolder, rootBlock, rootFolderEntry); }
public static LifFile Read(Stream stream) { using (var br = new BinaryReaderEx(stream, Encoding.UTF8, true)) { br.DefaultEndian = Endianness.BigEndian; ReadLifHeader(br); var lifFile = new LifFile(stream); ReadEntryHierarchy(lifFile, br); return(lifFile); } }
public ProgresHandler(LifFile lif, ExtractionProgressReportDelegate reportDelegate, CancellationToken cancellationToken) { Lif = lif; ReportDelegate = reportDelegate; CancellationToken = cancellationToken; CurrentEntryName = string.Empty; CurrentTargetPath = string.Empty; ExtractedFiles = 0; TotalFiles = 0; BytesExtracted = 0; TotalBytes = 0; }
public static PaletteFile FromLif(LifFile lif) { var bagEntry = lif.GetFile(Bag.FileName); if (bagEntry == null) { throw new InvalidDataException($"LIF file does not contains '{Bag.FileName}'"); } var file = new PaletteFile(Bag.Load(bagEntry.GetStream())); foreach (var paletteEntry in lif.GetFiles("*.paxml")) { file.Palettes.Add(Palette.FromLifEntry(paletteEntry)); } return(file); }
/// <summary> /// TODO /// </summary> /// <param name="folder"></param> public static LifFile CreateFromDirectory(DirectoryInfo folder) { var lif = new LifFile(); foreach (var entryInfo in folder.EnumerateFileSystemInfos("*", SearchOption.AllDirectories)) { if (entryInfo is FileInfo file) { string relativeDir = file.DirectoryName.Substring(folder.FullName.Length); var lifFolder = lif.GetFolder(relativeDir); if (lifFolder == null) { lifFolder = lif.CreateFolder(relativeDir); } lifFolder.AddFile(file); } } return(lif); }
public LifFile CreateLif() { var lif = new LifFile(); var ms = new MemoryStream(); GeneratePaletteNames(); Info.Save(ms); ms.Position = 0; lif.AddFile(ms, Bag.FileName); foreach (var palette in Palettes) { var paletteName = FileHelper.GetSafeFileName(palette.Name); ms = new MemoryStream(); palette.Save(ms); ms.Position = 0; lif.AddFile(ms, paletteName + ".paxml"); } return(lif); }
public static PaletteFile FromLif(string filepath) { using (var lif = LifFile.Open(filepath)) return(FromLif(lif)); }
internal FolderEntry(LifFile lif) : base(string.Empty) { _Lif = lif; Entries = new LifEntryCollection(this); IsRootDirectory = true; }