/
clamtk
executable file
·89 lines (79 loc) · 2.08 KB
/
clamtk
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/perl
#
# ClamTk, copyright (C) 2004-2024 Dave M
#
# This file is part of ClamTk
# https://github.com/dave-theunsub/clamtk/
# https://gitlab.com/dave_m/clamtk/
#
# ClamTk is free software; you can redistribute it and/or modify it
# under the terms of either:
#
# a) the GNU General Public License as published by the Free Software
# Foundation; either version 1, or (at your option) any later version, or
#
# b) the "Artistic License".
#
# use strict;
# use warnings;
use utf8;
$| = 1;
use ClamTk::Analysis;
use ClamTk::App;
use ClamTk::Assistant;
use ClamTk::GUI;
use ClamTk::History;
use ClamTk::Icons;
use ClamTk::Network;
use ClamTk::Prefs;
use ClamTk::Results;
use ClamTk::Scan;
use ClamTk::Schedule;
use ClamTk::Settings;
use ClamTk::Shortcuts;
use ClamTk::Startup;
use ClamTk::Update;
use ClamTk::Quarantine;
use ClamTk::Whitelist;
use Encode 'decode';
use Locale::gettext;
use POSIX 'locale_h';
textdomain( 'clamtk' );
setlocale( LC_ALL, '' );
# This seems horrible, but it works.
setlocale( LC_TIME, 'C' );
bind_textdomain_codeset( 'clamtk', 'UTF-8' );
my $arg = decode( 'utf8', $ARGV[ 0 ] );
#
# Unfortunately, I don't know how to make python keep a
# URI with spaces intact. So....
# my $arg = '';
# $arg = join( ' ', @ARGV );
# Might be in the Trash
# // = entire directory
my $trash_dir = ClamTk::App->get_path( 'trash_dir' );
if ( $arg eq '//' ) {
# The whole "Trash" directory
$arg = $trash_dir;
} elsif ( $arg =~ m#^//(.*?)$# ) {
# individual file
my $trash_dir_files = ClamTk::App->get_path( 'trash_dir_files' );
if ( -e "$trash_dir_files/$1" ) {
$arg = "$trash_dir_files/$1";
}
}
# Ensure all the normal directories are created
ClamTk::Prefs->structure;
# Ensure the preferences are normalized
# Create defaults if they do not exist
ClamTk::Prefs->custom_prefs;
# If we get no arguments, bring up GUI;
# otherwise, we're scanning.
# Let Scanner know this is a commandline scan, so
# if we can't scan (e.g. due to permissions), exit
if ( !$arg or !-e $arg ) {
ClamTk::GUI->start_gui();
} else {
ClamTk::Scan->filter( $arg, 1, 'startup' );
}
# End.