Alien-Win32-LZMA

 view release on metacpan or  search on metacpan

lib/Alien/Win32/LZMA.pm  view on Meta::CPAN


=head2 lzma_version

The C<lzma_version> function runs F<lzma.exe> and finds the version
of the application. It should match the version of this module.

=cut

sub lzma_version {
	my $exe    = lzma_exe();
	my $stderr = '';
	my $result = IPC::Run3::run3(
		[ $exe ],
		\undef,
		\undef,
		\$stderr,
	);
	unless ( $result ) {
		die "$exe execution failed";
	}
	unless  ( $stderr =~ /^\s*LZMA\s*([\d\.]+)/s ) {
		die "Failed to find LZMA version";
	}
	return "$1";
}

=pod

=head2 lzma_compress

  lzma_compress('file', 'file.lz') or die('Failed to compress');

t/02_main.t  view on Meta::CPAN

my $bin = Alien::Win32::LZMA->lzma_exe;
ok( -f $bin, 'Found lzma.exe' );
is(
	Alien::Win32::LZMA::lzma_exe(),
	$bin,
	'Can call lzma_exe as a function'
);

# Confirm it runs
my $stdout = '';
my $stderr = '';
my $result = IPC::Run3::run3(
	[ $bin ],
	\undef,
	\$stdout,
	\$stderr,
);
ok( $result, 'Ran lzma.exe ok' );
is( $stdout, '', 'STDOUT was empty' );
my $header = quotemeta('LZMA 4.65 : Igor Pavlov : Public domain : 2009-02-03');
like( $stderr, qr/$header/, 'lzma.exe output and version match expected values' );

# Check the lzma_version function
my $version = Alien::Win32::LZMA->lzma_version;
is( $version, 4.65, 'Found LZMA version 4.65 as expected' );





#####################################################################



( run in 0.555 second using v1.01-cache-2.11-cpan-49f99fa48dc )