RZ

01: # FileRealize.pl # wrapper for C++ code
02: # FileRealization.hh # the actual realize algorithm
03:
04: use strict;
05:
06: require "GetoptRealize.pl";
07: local( $::debug ) = GetoptRealize::debug();
08:
09: package FileRealize;
10:
11: ######## ######## ######## ######## ######## ######## ######## ######## ########
12:
13: my ( $RZ, $RECONSTITUTED );
14:
15: {
16:     local( $^F ) = 1<<31 - 1; # want our open files visible after exec
17:
18:     GetoptRealize::openh( departure => $RZ );
19:     GetoptRealize::differh( destination => $RZ );
20:
21:     print STDERR "  departure -> tempfiles\n" if $::debug;
22:
23:     open $RECONSTITUTED, "+>", undef or die "Can't open tempfile\n";
24: }
25:
26: {
27:     ######## ######## ######## wrap C++ code ######## ######## ########
28:
29:     my @DESCRIPTORS = map fileno( $_ ), ( $RZ, $RECONSTITUTED );
30:
31:     print STDERR
32:         "  fork and exec to C++ with descriptors @DESCRIPTORS\n" if $::debug;
33:
34:     system { $INC[0]."/FileRealize.gateway" } ( $0, @DESCRIPTORS ) and die
35:         "Realizer failure: $?\n";
36:
37:     ######## ######## ######## ######## ######## ######## ######## ########
38: }
39:
40: GetoptRealize::backh( departure => );
41: GetoptRealize::backh( destination => );
42:
43: {
44:     my $DESTINATION;
45:     GetoptRealize::converth( $RZ => $DESTINATION ) or (
46:         GetoptRealize::closeh( $RZ ),
47:         GetoptRealize::openh( destination => $DESTINATION ),
48:     );
49:
50:     print STDERR "  tempfiles -> destination\n" if $::debug;
51:
52:     while( read( $RECONSTITUTED, my $bk, 8192 ) ) { print $DESTINATION $bk; }
53:
54:     GetoptRealize::closeh( $DESTINATION );
55: }
56:
57: ######## ######## ######## ######## ######## ######## ######## ######## ########
58:
59: # FileRealize.pl # wrapper for C++ code
60:
61: 1;