This commit is contained in:
Eelco Dolstra 2014-07-24 12:24:25 +02:00
parent 01ddf53ee9
commit 56131a2709
2 changed files with 21 additions and 8 deletions

View file

@ -27,13 +27,7 @@ sub copyToOpen {
# Get back the set of paths that are already valid on the remote host. # Get back the set of paths that are already valid on the remote host.
my %present; my %present;
my $n = readInt($from); $present{$_} = 1 foreach readStrings($from);
while ($n--) {
my $len = readInt($from);
my $s = readN($len, $from);
$present{$s} = 1;
readN(8 - $len % 8, $from) if $len % 8; # skip padding
}
my @missing = grep { !$present{$_} } @closure; my @missing = grep { !$present{$_} } @closure;
return if !@missing; return if !@missing;

View file

@ -7,7 +7,8 @@ use IPC::Open2;
our @ISA = qw(Exporter); our @ISA = qw(Exporter);
our @EXPORT = qw( our @EXPORT = qw(
sshOpts openSSHConnection closeSSHConnection sshOpts openSSHConnection closeSSHConnection
readN readInt writeInt writeString writeStrings readN readInt readString readStrings
writeInt writeString writeStrings
connectToRemoteNix connectToRemoteNix
); );
@ -83,6 +84,24 @@ sub readInt {
} }
sub readString {
my ($from) = @_;
my $len = readInt($from);
my $s = readN($len, $from);
readN(8 - $len % 8, $from) if $len % 8; # skip padding
return $s;
}
sub readStrings {
my ($from) = @_;
my $n = readInt($from);
my @res;
push @res, readString($from) while $n--;
return @res;
}
sub writeInt { sub writeInt {
my ($n, $to) = @_; my ($n, $to) = @_;
syswrite($to, pack("L<x4", $n)) or die; syswrite($to, pack("L<x4", $n)) or die;