File Coverage

lib/SMB/Tree.pm
Criterion Covered Total %
statement 12 38 31.5
branch 0 4 0.0
condition 0 17 0.0
subroutine 4 16 25.0
pod 1 12 8.3
total 17 87 19.5


line stmt bran cond sub pod time code
1             # SMB-Perl library, Copyright (C) 2014 Mikhael Goikhman, migo@cpan.org
2             #
3             # This program is free software: you can redistribute it and/or modify
4             # it under the terms of the GNU General Public License as published by
5             # the Free Software Foundation, either version 3 of the License, or
6             # (at your option) any later version.
7             #
8             # This program is distributed in the hope that it will be useful,
9             # but WITHOUT ANY WARRANTY; without even the implied warranty of
10             # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11             # GNU General Public License for more details.
12             #
13             # You should have received a copy of the GNU General Public License
14             # along with this program. If not, see .
15              
16             package SMB::Tree;
17              
18 1     1   5 use strict;
  1         1  
  1         28  
19 1     1   4 use warnings;
  1         3  
  1         26  
20              
21 1     1   5 use parent 'SMB';
  1         1  
  1         6  
22              
23 1     1   56 use SMB::File;
  1         2  
  1         424  
24              
25             sub new ($$$%) {
26 0     0 1   my $class = shift;
27 0   0       my $share = shift || die "No share in constructor";
28 0   0       my $id = shift || die "No tree id in constructor";
29 0           my %options = @_;
30              
31 0   0       $options{addr} //= undef; # remote
32 0   0       $options{root} //= undef; # local
33              
34 0           my $self = $class->SUPER::new(
35             %options,
36             share => $share,
37             id => $id,
38             );
39              
40 0 0 0       die "Neither 'root' for local tree nor 'addr' for remote tree in constructor"
41             unless $self->is_local || $self->is_remote;
42              
43 0           return $self;
44             }
45              
46             sub is_ipc ($) {
47 0     0 0   my $self = shift;
48              
49 0           return $self->share eq 'IPC$';
50             }
51              
52             sub is_local ($) {
53 0     0 0   my $self = shift;
54              
55 0   0       return $self->root || $self->is_ipc;
56             }
57              
58             sub is_remote ($) {
59 0     0 0   my $self = shift;
60              
61 0   0       return $self->addr && $self->client;
62             }
63              
64             sub perform_remote_command ($$@) {
65 0     0 0   my $self = shift;
66 0           my $command = shift;
67              
68 0 0         die unless $self->is_remote;
69              
70 0           $self->client->perform_tree_command($self, $command, @_);
71             }
72              
73 0     0 0   sub chdir { shift()->perform_remote_command('chdir', @_); }
74 0     0 0   sub find { shift()->perform_remote_command('find', @_); }
75 0     0 0   sub dnload { shift()->perform_remote_command('dnload', @_); }
76 0     0 0   sub upload { shift()->perform_remote_command('upload', @_); }
77 0     0 0   sub copy { shift()->perform_remote_command('copy', @_); }
78 0     0 0   sub rename { shift()->perform_remote_command('rename', @_); }
79 0     0 0   sub remove { shift()->perform_remote_command('remove', @_); }
80              
81             1;