File: rx_auto

package info (click to toggle)
vfu 4.16%2Brepack-1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 2,652 kB
  • ctags: 4,212
  • sloc: cpp: 16,503; ansic: 12,357; perl: 598; makefile: 564; sh: 61
file content (49 lines) | stat: -rwxr-xr-x 1,280 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/perl
#############################################################################
#
# rx_* dispatcher and handlers for VFU File Manager
# (c) Vladi Belperchinov-Shabanski "Cade" 2002
# <cade@biscom.net> <cade.datamax.bg> http://cade.webbg.com
# $Id: rx_auto,v 1.5 2006/08/05 20:15:40 cade Exp $
#
# usage:
#   rx_* l archive directory   # list archive directory
#   rx_* v archive             # list entire archive
#   rx_* x archive files...    # extract one file
#   rx_* x archive @listfile   # extract list of files
#
#############################################################################
use strict;

my $CTTL = 16; # cache time to live in seconds

my $file = $ARGV[1];

for( glob "/tmp/*.rx.cache" )
  {
  # clean cache--silently skip errors
  next unless time() - file_mtime( $_ ) > $CTTL;
  unlink $_;
  }

my $rx = choose( $file ) or die "$0: this file type is not nown to me, sorry\n";

exec( $rx, @ARGV );

sub choose
{
  local $_ = shift;
  return "rx_tar" if /\.(?:tar(?:\.(?:z|gz|bz2))?|t[bgx]z)$/i;
  return "rx_zip" if /\.(?:zip|jar|pk3|egg|maff)$/i;
  return "rx_deb" if /\.deb$/i;
  return "rx_ftp" if /\.ftp$/i;
  return "rx_rar" if /\.rar$/i;
  return "rx_rpm" if /\.rpm$/i;
  return undef;
}

sub file_mtime
{
  return (stat($_[0]))[9];
}