X-Git-Url: https://git.p6c8.net/devedit.git/blobdiff_plain/5abe8188abba8d1d5931b84d36d719c7ef3aee36..77fef5e4b082959ff9154a3622c1f5406dea6d3b:/modules/Tool.pm?ds=sidebyside diff --git a/modules/Tool.pm b/modules/Tool.pm index 95b64dd..49f255b 100644 --- a/modules/Tool.pm +++ b/modules/Tool.pm @@ -6,7 +6,7 @@ package Tool; # Some shared sub routines # # Author: Patrick Canterino -# Last modified: 2010-12-23 +# Last modified: 2011-01-05 # # Copyright (C) 1999-2000 Roland Bluethgen, Frank Schoenmann # Copyright (C) 2003-2009 Patrick Canterino @@ -40,12 +40,18 @@ use base qw(Exporter); encode_html equal_url file_name + is_archive in_array is_disabled_command is_forbidden_file mode_string multi_string upper_path); + +my @archive_exts = ('.zip', '.tar', '.gz', + '.tar.gz', '.tgz', '.bz2', + '.tar.bz2', '.tbz', '.tbz2', + '.Z'); # check_path() # @@ -287,8 +293,27 @@ sub in_array($$) return 1 if($string eq $element); } - #foreach + 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; } @@ -308,7 +333,7 @@ sub is_disabled_command($$) foreach my $entry(@$list) { - return 1 if(uc($command) eq uc($entry)); + return 1 if(lc($command) eq lc($entry)); } return;