
# This code is shared by all the ICEM CFD GUI's.
#
# Copyright (c) 1993 - 1995 Pacific Marketing and Consulting, Inc,
#       and ICEM Systems, GmbH.  All rights reserved.
# Author:  Wayne A. Christopher, wayne@icemcfd.com

this_file_is_never_used

set rebuild_digest 0
set compile_tcl 0

foreach arg $argv {
    if ![string compare $arg -rd] { set rebuild_digest 1 }
    if ![string compare $arg -ct] { set compile_tcl 1 }
}

proc load_fileset {dir dfiles ifiles} {
    global rebuild_digest source_dirs
    
    if $rebuild_digest {
	set files ""
	puts "Rebuilding digest $dir/digest..."
	set out [open $dir/digest.in w]
	foreach f $dfiles {
	    set fp [open $dir/$f.tcl r]
	    set stuff [read $fp]
	    close $fp
	    puts $out $stuff nonewline
	}
	close $out
	digest create $dir/digest $dir/digest.in
	cmd_rm $dir/digest.in
    }
    
    set dmtime 0
    if {([info commands digest] != "") && [file exists $dir/digest]} {
	set dmtime [file mtime $dir/digest]
	puts "Loading digest $dir/digest"
	uplevel \#0 digest load $dir/digest
    }
    
    foreach f $dfiles {
	set file $dir/$f.tcl
	if {[file exists $file] && ([file mtime $file] > $dmtime)} {
	    if $dmtime { puts "Loading file $f.tcl" }
	    uplevel \#0 source $file
	}
    }
    foreach f $ifiles {
	set file $dir/$f.tcl
	if $dmtime { puts "Loading file $f.tcl" }
	uplevel \#0 source $file
    }
    lappend source_dirs $dir
}
