+# archive_unpack()
+#
+# Unpack an archive
+# (archive type must be supported by Archive::Extract)
+#
+# Params: 1. Archive path
+# 2. Path to extract (optional)
+#
+# Return: - Status code (Boolean)
+# - undef if Archive::Extract is not available
+
+sub archive_unpack($;$)
+{
+ my ($archive,$path) = @_;
+
+ return undef unless($has_archive_extract);
+
+ return unless(-f $archive);
+ return if($path && not -d $path);
+
+ my $ae = Archive::Extract->new(archive => $archive);
+ return unless($ae);
+
+ if($path)
+ {
+ if($ae->extract(to => $path))
+ {
+ return 1;
+ }
+ else
+ {
+ $archive_extract_error = $ae->error;
+ return;
+ }
+ }
+ else
+ {
+ if($ae->extract)
+ {
+ return 1;
+ }
+ else
+ {
+ $archive_extract_error = $ae->error;
+ return;
+ }
+ }
+}
+