CPIO composition
Overview
CPIO (Copy In, Copy Out) is an archive format used primarily in Unix-like operating systems for packaging multiple files and directories into a single archive. Although less commonly used than formats such as TAR or ZIP, CPIO remains relevant for certain systems and workflows, especially for backups and software packaging. Aspose.ZIP for .NET provides support for creating and managing CPIO archives within .NET applications. You can package files into a CPIO archive by adding entries and saving the archive, similar to how you would work with other archive formats. Cpio format is similar to Tar, allowing multiple files to be combined into one archive, which may then be compressed for easier storage or transfer.
Collecting without compression
The following example shows how to combine two files into a CPIO archive:
1 using (FileStream cpioFile = File.Open("combined.cpio", FileMode.Create))
2 {
3 FileInfo fi1 = new FileInfo("alice29.txt");
4 FileInfo fi2 = new FileInfo("asyoulik.txt");
5
6 using (CpioArchive archive = new CpioArchive())
7 {
8 archive.CreateEntry("alice29.txt", fi1);
9 archive.CreateEntry("asyoulik.txt", fi2);
10 archive.Save(cpioFile, format);
11 }
12 }Compressing cpio archive
On Unix-like operating systems, the cpio utility allows compressing cpio archive to gzip on creation. Aspose.ZIP mirrors this functionality through the
SaveGzipped method.
1 using (var archive = new CpioArchive())
2 {
3 archive.CreateEntries("C:\\folder", false);
4 archive.SaveGzipped("result.cpio.gz");
5 }Nowadays xz utility has become popular in Linux and Unix. Its compression of cpio is seamlessly integrated into Aspose.Zip. Use the SaveXzCompressed method of a cpio archive.
1 using (var archive = new CpioArchive())
2 {
3 archive.CreateEntries("C:\\folder", false);
4 archive.SaveXzCompressed("result.cpio.xz");
5 }