#!/usr/bin/perl

# Objective: Port to unix systems, does not need to autorun the ram file, just tell
# user where to find it 

# like

# print "Please open $outfile in your realplayer now";

# Replace registry crap with method of finding realplay on user's system.. uhm..
# I will get the BlackJack url later for user to download realplayer (not gonna
# include every unix port on earth on the cd.

use cwd;
$infile    = "files/real.ini";
$outfile   = "$ENV{TEMP}/sonicrealcd.ram";
$pathfile  = "files/path.ini";
$cwd       = cwd();
$mountpoint = $cwd;
$count     = 0;
open( PATH, "$pathfile" ) || die ("Can't open $pathfile");
$path = <PATH>;
close(PATH);

open( LIST, "$infile" ) || die ("Can't open $infile");
flock LIST, LOCK_EX;
$size = 0;
while (<LIST>) {
    $array[$size] = $_;
    $size++;
}
seek( LIST, 0, 0 );
open( OUT, ">$outfile" );
while ( $size > 0 ) {
    $n = ( int rand() * $size * 10 ) % $size;

    print OUT "file://$mountpoint/$pathslash/$array[$n]";

    $array[$n] = $array[ $size - 1 ];
    $size--;
}

close(LIST);
close(OUT);

print "Please load $outfile into your XFree86 RealPlayer now..";
exit;
