#!/usr/bin/perl -w

use strict;
require 'MDSDir.pl';
require 'MDSTop.pl';
require 'MDSInfo.pl';
require 'MDSList.pl';
require 'MDSMainFrame.pl';

sub BuildHash
{
    my ( $Opts, $Dirs, $Pass, $Output ) = @_[0..3];
    
    die "no passwd" if( $Pass ne $Opts->{'passwd'} );


    open FH, ">", $Opts->{'hash'};

    print FH "{\n";

    for( my $o = 0; $o < $#{$Dirs}; $o += 2 )
    {
        my $Dir = $Dirs->[$o+1];
        
        open FILE, "cd $Dir; find . -maxdepth 1 -iname \"*.m\" ".
            "-and ! -iname \"contents.m\" | sort |"  ;
        
        while( <FILE> )
        {
            chomp;
            s/^\.\///;
            s/\.m$//;
            print FH "\"$_\" => [ " . ($o/2) . ", \"$_.m\"],\n";
        }
        close FILE;
    }
    print FH "};\n";

    close FH;
}

1;
