summaryrefslogtreecommitdiff
path: root/Tools/schnitt/schnitt2.pl
blob: e52b24595da081438cfe1086ae0490f763c28c6b (plain)
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
90
91
#!/usr/bin/perl

require "/usr/local/bin/my/schnittcommon.pli";

if (!open (INDEX,"index.vdr"))
  {
    print "Error opening index.vdr";
    exit 1;
  }

$index = $ARGV[0];
&nextI;
$file1 = $file;
$offset1 = $offset;
$index = $ARGV[1];
&nextI;
$file2 = $file;
$offset2 = $offset;

if ($file1 == $file2)
  {
    $count = $offset2 - $offset1;
    $cond = 0;
    $size = 1024*1024;
    $fi = sprintf ("%03d.vdr",$file);
    open (FI,$fi);
    sysseek (FI,$offset1,0);
    while ($cond == 0)
      {
	if ($count > $size)
	  {
	    $read = sysread (FI,$data,$size);
            print $data;
	    $count -= $size;
	  }
	else
	  {
	    $read = sysread (FI,$data,$count);
            print $data;
	    $cond = 1;
	  }
      }
  }
else
  {
    $count = $offset2;
    $cond = 0;
    $read = $size = 1024*1024;
    $fi = sprintf ("%03d.vdr",$file1);
    open (FI,$fi);
    sysseek (FI,$offset1,0);
    while ($read == $size)
      {
	$read = sysread (FI,$data,$size);
        print $data;
      }
    close (FI);

    $file1++;
    while ($file1 != $file2)
      {
        $fi = sprintf ("%03d.vdr",$file1);
        open (FI,$fi);
        $read = 1024*1024;        
        while ($read == $size)
          {
            $read = sysread (FI,$data,$size);
            print $data;
          }
        close (FI);
        $file1++;
      }

    $fi = sprintf ("%03d.vdr",$file2);
    open (FI,$fi);
    while ($cond == 0)
      {
	if ($count > $size)
	  {
	    $read = sysread (FI,$data,$size);
            print $data;
	    $count -= $size;
	  }
	else
	  {
	    $read = sysread (FI,$data,$count);
            print $data;
	    $cond = 1;
	  }
      }
  }