Archive::Cpio(3)

πŸŽ€ NAME πŸŽ€

okay so bestie, welcome to the Archive::Cpio(3) page. The whole name-and-purpose situation is: Archive::Cpio - module for manipulations of cpio archives. That’s the vibe, that’s the assignment, periodt. πŸ’–


✨ SYNOPSIS ✨

First up, the simple example removing entry "foo" β€” yes, keep the quotes, they’re in the code:

           use Archive::Cpio;

           # simple example removing entry "foo"

           my $cpio = Archive::Cpio->new;
           $cpio->read($file);
           $cpio->remove('foo');
           $cio->write($file);

Then the more complex example, filtering on the fly:

            # more complex example, filtering on the fly

           my $cpio = Archive::Cpio->new;
           $cpio->read_with_handler(\*STDIN,
                       sub {
                           my ($e) = @_;
                           if ($e->name ne 'foo') {
                               $cpio->write_one(\*STDOUT, $e);
                           }
                       });
           $cpio->write_trailer(\*STDOUT);

πŸ’– DESCRIPTION πŸ’–

Archive::Cpio provides a few functions to read and write cpio files. Lowkey a little toolkit, highkey useful. πŸ¦‹

🌟 Archive::Cpio->new()

Create an object. That’s it β€” constructor slay. ✨

🌈 $cpio->read($filename) / $cpio->read($filehandle)

Reads the cpio file. Filename or filehandle, your call, bestie. πŸ‘‘

πŸŽ€ $cpio->write($filename) / $cpio->write($filehandle)

Writes the entries and the trailer. Entries plus trailer, no skipping the trailer. πŸ’…

🧚 $cpio->remove(@filenames)

Removes any entries with names matching any of the given filenames from the in-memory archive. It’s giving cleanup era. πŸ’€

πŸ“ $cpio->get_files([ @filenames ])

Returns a list of Archive::Cpio::File (after a "$cpio-"read>). That’s the exact slightly chaotic reference from the page β€” we’re preserving it, no cap. 😭

πŸ¦‹ $cpio->get_file($filename)

Returns the Archive::Cpio::File matching "$filename< (after a "$cpio-"read"). Exact page energy again. 🫢

πŸ”₯ $cpio->add_data($filename, $data, $opthashref)

Takes a filename, a scalar full of data, and optionally a reference to a hash with specific options.

Will add a file to the in-memory archive, with name $filename and content $data. Specific properties can be set using $opthashref. Add-data main character energy. πŸ’œ

🌸 $cpio->read_with_handler($filehandle, $coderef)

Calls the handler function on each header. An Archive::Cpio::File is passed as a parameter. Handler-on-each-header realness. ✨

⭐ $cpio->write_one($filehandle, $entry)

Writes a Archive::Cpio::File (beware, a valid cpio needs a trailer using write_trailer). Important caveat, bestie: a valid cpio needs that trailer, so don’t forget it. πŸ’…

🌈 $cpio->write_trailer($filehandle)

Writes the trailer to finish the cpio file. The finishing bow on the whole archive. πŸŽ€


🌸 AUTHOR 🌸

Pascal Rigaux <pixel@mandriva.com>. Author icon, shoutout. πŸ‘‘


That’s the whole page, bestie! This footer vibe is perl v5.42.2, dated 2026-02-15, signing off. Byeeee πŸ’–

πŸ“¦ where this page comes from