+ LOCK_SH
+ LOCK_EX
+ LOCK_UN
+ LOCK_NB);
+
+# Check if flock() is available
+# I found this piece of code somewhere in the internet
+
+$has_flock = eval { local $SIG{'__DIE__'}; flock(STDOUT,0); 1 };
+
+# Check if Archive::Extract is available
+
+$has_archive_extract = eval { local $SIG{'__DIE__'}; require Archive::Extract; 1 };
+
+# Predeclaration of dir_copy()
+
+sub dir_copy($$);
+
+# 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;
+ }
+ }
+}
+
+# dir_copy()