[Functions] ROBOTestFrame/add_source

[top][parent][index]

FUNCTION

Add a single source file somewhere in Src/

SOURCE

sub add_source
{
    my $filepath = shift;
    my $source   = shift;

    my $dir_name = "$src" . dirname( $filepath );

    if ( ! -e "$dir_name" ) {
        mkpath $dir_name or die "can't create $dir_name";
    }

    my $full_filepath = "$src/$filepath";
    my $file = IO::File->new(">$full_filepath") or die "Can't open $full_filepath";
    print $file $source;
    $file->close();
}