/*****************************************************************************************
This file and the java class Calljsac are used by Visual JavaScript.  Do not alter or
delete them or remove this application, or Visual JavaScript will not work properly.
*****************************************************************************************/

function ConvertToWinFormat(pathStr) {
	sep = "\\\\"
	newStr = pathStr
	while ( newStr.indexOf("/") != -1 )
		newStr = replace(newStr, "/", sep)
	return newStr
}

// Helper function
function replace(str, pattern, withWhat) {
	x = str.indexOf(pattern)
	if (x != -1) {
		before = str.substring(0, x)
		after = str.substring(x+1, str.length)
		str = before + withWhat + after
	}
	return str
}

/*
This script expects the following request parameters:
* path = the full local file path to the directory containing the source files.  Output will go here, too.
* projName = Name of web file to create

Also, it assumes there is a filelist file in the "path" directory containing names of all files to compile,
and that jsac.exe is on the current PATH.

Notes:
The directory containing the java class Calljsac must be in the system's CLASSPATH.
For example, if the compiler app is in D:\Netscape\SuiteSpot\js\samples\compiler, the call below assumes
that the CLASSPATH points to D:\Netscape\SuiteSpot\js\samples.
*/

if (server.jsVersion.indexOf("NT") == -1)
	WinNT = false
else
	WinNT = true

if (WinNT) {
    jsacPath = "jsac"
    deployDir = ConvertToWinFormat( request.path )
}
else {
      jsacPath = "jsac" //--- Use jsac on Unix, too --"/usr/netscape/suitespot/bin/https/jsac"
	deployDir = request.path
}

write("
") write("Calling compiler") var str = Packages.compiler.Calljsac.exec( jsacPath, deployDir, "filelist", request.projName , true ); write("

" + str );