X-Git-Url: https://git.p6c8.net/devedit.git/blobdiff_plain/c2b18d37a29420fc5b1e33c19a0e69d00016c621..3b69a56ae05c5a9f8de83528657cefd784c95a8f:/modules/Tool.pm diff --git a/modules/Tool.pm b/modules/Tool.pm index ccb78af..2f72d1a 100644 --- a/modules/Tool.pm +++ b/modules/Tool.pm @@ -6,10 +6,10 @@ 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 +# Copyright (C) 2003-2011 Patrick Canterino # All Rights Reserved. # # This file can be distributed and/or modified under the terms of @@ -41,12 +41,18 @@ use base qw(Exporter); equal_url file_name in_array + is_archive 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() # # Check if a virtual path is above a virtual root directory @@ -287,7 +293,26 @@ 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; }