ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/File-Rdiff/rdiff2
Revision: 1.1
Committed: Thu Mar 21 23:49:01 2002 UTC (22 years, 3 months ago) by root
Branch: MAIN
Log Message:
*** empty log message ***

File Contents

# Content
1 #!/usr/bin/perl
2
3 use File::Rdiff qw(:trace :nonblocking);
4
5 trace_level(LOG_INFO);
6
7 if ($ARGV[0] eq "signature") {
8 open $basis, "<", $ARGV[1]
9 or die "$ARGV[1]: $!";
10 open $sig, ">", $ARGV[2]
11 or die "$ARGV[2]: $!";
12
13 my $job = new_sig File::Rdiff::Job;
14 my $buf = new File::Rdiff::Buffers 4096;
15
16 while ($job->iter($buf) == BLOCKED) {
17 # fetch more input data
18 $buf->avail_in or do {
19 my $in;
20 65536 == sysread $basis, $in, 65536
21 or $buf->eof;
22 $buf->in($in);
23 };
24 print $sig $buf->out;
25 }
26
27 # the last time
28 print $sig $buf->out;
29 } elsif ($ARGV[0] eq "delta") {
30 open $sig, "<$ARGV[1]" or die "$ARGV[1]: $!";
31 open $new, "<$ARGV[2]" or die "$ARGV[2]: $!";
32 open $delta, ">$ARGV[3]" or die "$ARGV[3]: $!";
33
34 # first load the signature into memory
35 $sig = loadsig_file $sig;
36
37 ref $sig or exit 1;
38
39 $sig->build_hash_table;
40
41 File::Rdiff::delta_file $sig, $new, $delta;
42 } elsif ($ARGV[0] eq "patch") {
43 open $base, "<$ARGV[1]" or die "$ARGV[1]: $!";
44 open $delta, "<$ARGV[2]" or die "$ARGV[2]: $!";
45 open $new, ">$ARGV[3]" or die "$ARGV[3]: $!";
46
47 File::Rdiff::patch_file $base, $delta, $new;
48 } else {
49 print <<EOF;
50 $0 signature BASIS SIGNATURE
51 $0 delta SIGNATURE NEW DELTA
52 $0 patch BASE DELTA NEW
53 EOF
54 exit (1);
55 }
56