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 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
package VCP::Source::null ;
=head1 NAME
VCP::Source::null - A null source, for testing purposes
=head1 SYNOPSIS
vcp null:
=head1 DESCRIPTION
Takes no options, delivers no data.
=cut
$VERSION = 1.0 ;
@ISA = qw( VCP::Source );
use strict ;
use Carp ;
use File::Spec;
use File::Temp;
use VCP::Debug ":debug" ;
use VCP::Source;
use VCP::Utils qw( is_win32 );
#use base qw( VCP::Source );
sub new {
my $self = shift->SUPER::new;
## Parse the options
my ( $spec, $options ) = @_ ;
die "vcp: the null source takes no spec ('$1')\n"
if defined $spec && $spec =~ m{\Anull:(.+)}i;
$self->repo_id( "null" );
$self->parse_repo_spec( $spec ) if defined $spec;
$self->parse_options( $options );
return $self ;
}
sub options_spec {
return ();
}
sub handle_header {
my $self = shift ;
my ( $header ) = @_ ;
$self->dest->handle_header( $header );
return ;
}
my $null_fn;
sub get_source_file {
my $self = shift;
my ( $r ) = @_;
if ( !defined $null_fn ) {
## On Win32, "NUL" is not a file like '/dev/null' is on Unix,
## so you can't link() to it. Also, we need to be on the same
## file system as the other temp files for link()'s sake.
my $fh;
( $fh, $null_fn ) = File::Temp::tempfile(
"vcp_empty_file_XXXX",
UNLINK => 1
);
close $fh;
## close it so files link()ed to this one may be unlink()ed
## on Win32
}
return $null_fn;
}
=head1 SEE ALSO
L<VCP::Dest::null>, L<vcp>.
=head1 AUTHOR
Barrie Slaymaker <barries@slaysys.com>
=head1 COPYRIGHT
Copyright (c) 2000, 2001, 2002 Perforce Software, Inc.
All rights reserved.
See L<VCP::License|VCP::License> (C<vcp help license>) for the terms of use.
=cut
1
|