### Writing a CPIO archive with UnixInMemoryFileSystem Source: https://github.com/xenoatom/xenoatom.unixtools/blob/main/readme.md Creates an in-memory file system, adds directories and a file, then writes the file system to a CPIO archive using CpioWriter. The writer is disposed after writing. ```csharp var stream = new MemoryStream(); var fs = new UnixInMemoryFileSystem(); fs.CreateDirectory("/dir1"); fs.CreateDirectory("/dir1/dir2"); fs.CreateFile("/dir1/file1.txt", "Hello World"); { using var writer = new CpioWriter(File.Create("archive.cpio")); fs.WriteTo(writer); } ``` -------------------------------- ### Reading a CPIO archive with CpioReader Source: https://github.com/xenoatom/xenoatom.unixtools/blob/main/readme.md Opens a CPIO archive file and iterates through its entries, printing each entry's name, file type, and mode. The reader is used in a while loop with TryGetNextEntry. ```csharp var cpioReader = new CpioReader(File.OpenRead("archive.cpio")); while (cpioReader.TryGetNextEntry(out var entry)) { Console.WriteLine($"Entry: {entry.Name} {entry.FileType} ({entry.Mode})"); }) ```