private void RunForFile(Stream currentInputStream, string currentInputPath, string currentOutputPath, bool keepOutputPath) { if (Mode == GxExpanderMode.Unpack && GetDotExtension(currentInputPath) == "lz") { // Unpack .LZ file using (Stream outputStream = new MemoryStream()) { Lz.Unpack(currentInputStream, outputStream, Game); outputStream.Position = 0; // Need to continue unpacking for .arc.lz RunForFile(outputStream, DotExtToCommaExt(currentInputPath), !keepOutputPath ? DotExtToCommaExt(currentOutputPath) : currentOutputPath, keepOutputPath); } } else if (Mode == GxExpanderMode.Pack && GetCommaExtension(currentInputPath) == "lz") { // Pack .LZ file using (Stream outputStream = new MemoryStream()) { Lz.Pack(currentInputStream, outputStream, Game); outputStream.Position = 0; RunForFile(outputStream, CommaExtToDotExt(currentInputPath), !keepOutputPath ? CommaExtToDotExt(currentOutputPath) : currentOutputPath, keepOutputPath); } } else if (Mode == GxExpanderMode.Unpack && GetDotExtension(currentInputPath) == "arc") { // Unpack .ARC container ArcContainer arc = new ArcContainer(currentInputStream); arc.Extract(!keepOutputPath ? DotExtToCommaExt(currentOutputPath) : currentOutputPath); // No need to continue unpacking inside .arc files } else { // Copy the file as-is without change using (FileStream currentOutputStream = File.Create(currentOutputPath)) { currentInputStream.CopyTo(currentOutputStream); } } }