]> git.p6c8.net - devedit.git/blobdiff - modules/Tool.pm
Added rudimentary support for unpacking archive files using Archive::Extract.
[devedit.git] / modules / Tool.pm
index e810c8b70a94454937060b00b246dfb7be058bd3..4dc6fa29e50d7b9aea731cb7d8a00d0f63d1ef5d 100644 (file)
@@ -40,12 +40,15 @@ use base qw(Exporter);
              encode_html
              equal_url
              file_name
              encode_html
              equal_url
              file_name
+             is_archive
              in_array
              is_disabled_command
              is_forbidden_file
              mode_string
              multi_string
              upper_path);
              in_array
              is_disabled_command
              is_forbidden_file
              mode_string
              multi_string
              upper_path);
+             
+my @archive_exts = ('.zip', 'tar.gz', 'tar.bz2');
 
 # check_path()
 #
 
 # check_path()
 #
@@ -290,6 +293,27 @@ sub in_array($$)
  return;
 }
 
  return;
 }
 
+# is_archive()
+#
+# Check if a file is an archive
+# (currently only by file extension)
+#
+# Params: Archive file name
+#
+# Return: Status code (Boolean)
+
+sub is_archive($)
+{
+ my $file = shift;
+ foreach my $ext(@archive_exts)
+ {
+  return 1 if(lc(substr($file,length($file)-length($ext),length($ext))) eq lc($ext));
+ }
+ return;
+}
+
 # is_disabled_command()
 #
 # Check if a command is disabled
 # is_disabled_command()
 #
 # Check if a command is disabled

patrick-canterino.de