DEV Community

Yuki Kimoto - SPVM Author
Yuki Kimoto - SPVM Author

Posted on

Create foo.a using Pure Perl and Archive::Ar

I'm searching for the way to create static library such as "foo.a".

I found Archive::Ar on CPAN.

use Archive::Ar;

my $ar = Archive::Ar->new;

$ar->read('./foo.ar');
$ar->extract;

$ar->add_files('./bar.tar.gz', 'bat.pl')
$ar->add_data('newfile.txt','Some contents');

$ar->chmod('file1', 0644);
$ar->chown('file1', $uid, $gid);

$ar->remove('file1', 'file2');

my $filehash = $ar->get_content('bar.tar.gz');
my $data = $ar->get_data('bar.tar.gz');
my $handle = $ar->get_handle('bar.tar.gz');

my @files = $ar->list_files();

my $archive = $ar->write;
my $size = $ar->write('outbound.ar');

$ar->error();
Enter fullscreen mode Exit fullscreen mode

I'm working to create SPVM.

SPVM has C/C++ binding tools.

Top comments (0)