Details | Last modification | View Log | SVN | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1522 | arune | 1 | #!/usr/bin/perl |
| 2 | |||
| 3 | use File::Basename; |
||
| 4 | use Cwd 'abs_path'; |
||
| 5 | |||
| 6 | $defaultbin = "/usr/bin/meld"; |
||
| 7 | |||
| 8 | @extensionbin = ( |
||
| 9 | "brd", "/home/arune/Documents/HomeAutomation/PcSoftware/scripts/eagleDiff/eagle-diff.pl", |
||
| 10 | "sch", "/home/arune/Documents/HomeAutomation/PcSoftware/scripts/eagleDiff/eagle-diff.pl" |
||
| 11 | ); |
||
| 12 | |||
| 13 | #check number of arguments, must be 2 |
||
| 14 | my $argcount = @ARGV; |
||
| 15 | if (not $argcount eq "2") { |
||
| 16 | print "Syntax: compare-bin-chooser.pl <file1> <file2>\n"; |
||
| 17 | exit; |
||
| 18 | } |
||
| 19 | |||
| 20 | #read arguments and find file suffix |
||
| 21 | my $file1 = $ARGV[0]; |
||
| 22 | my $file2 = $ARGV[1]; |
||
| 23 | my(undef, undef, $suffix1) = fileparse($file1,qr"\..*"); |
||
| 24 | my(undef, undef, $suffix2) = fileparse($file2,qr"\..*"); |
||
| 25 | |||
| 26 | #check that files exists |
||
| 27 | unless (-e $file1) |
||
| 28 | { |
||
| 29 | print "File '$file1' does not exist.\n"; |
||
| 30 | } |
||
| 31 | unless (-e $file2) |
||
| 32 | { |
||
| 33 | print "File '$file2' does not exist.\n"; |
||
| 34 | } |
||
| 35 | #check that both files have the same suffix |
||
| 36 | unless ($suffix1 eq $suffix2) |
||
| 37 | { |
||
| 38 | print "File '$file1' does not have the same file type as '$file2'.\n"; |
||
| 39 | } |
||
| 40 | |||
| 41 | my $extbinlen = @extensionbin; |
||
| 42 | my $foundbin = false; |
||
| 43 | for (my $i; $i < $extbinlen; $i +=2) |
||
| 44 | { |
||
| 45 | if ($suffix1 eq ".".@extensionbin[$i]) |
||
| 46 | { |
||
| 47 | unless (-e @extensionbin[$i+1]) |
||
| 48 | { |
||
| 49 | print "Binary ".@extensionbin[$i+1]." does not exist.\n"; |
||
| 50 | } |
||
| 51 | system (@extensionbin[$i+1], $file1, $file2); |
||
| 52 | $foundbin = true; |
||
| 53 | } |
||
| 54 | } |
||
| 55 | if ($foundbin eq false) |
||
| 56 | { |
||
| 57 | system ($defaultbin, $file1, $file2); |
||
| 58 | } |
||
| 59 | |||
| 60 |