library/src/javascript/BP-Javascript.cc
// Attempts to run a script from a given file path.
Attempts to run a script from a given file path.
Attempts to run a script from a given file path .
BP_ERROR_T BP_JSRunScriptFromFile(P_BP_JS_MANAGER mgr, char *path_to_script)
{
	if(!path_to_script)
		return ERR_FAILURE;
	if(!BP_StringIsReasonablePrintableString(path_to_script, bpstrlen(path_to_script), BP_FALSE, BP_FALSE))
		return ERR_FAILURE;
	if(BP_FileAtPathExistsAndIsReadable(path_to_script) != ERR_SUCCESS)
		return ERR_FAILURE;
	char * script_content = BP_FileGetContents(path_to_script);
	if(!script_content)
		return ERR_FAILURE;
	if(BP_JSRunScript(mgr, script_content, bpstrlen(script_content)-1) == ERR_FAILURE)
		return ERR_FAILURE;
	return ERR_SUCCESS;
}
BP_ERROR_T BP_JSRunScriptFromFile ( P_BP_JS_MANAGER mgr , char * path_to_script ) { if ( ! path_to_script ) return ERR_FAILURE ; if ( ! BP_StringIsReasonablePrintableString ( path_to_script , bpstrlen ( path_to_script ) , BP_FALSE , BP_FALSE ) ) return ERR_FAILURE ; if ( BP_FileAtPathExistsAndIsReadable ( path_to_script ) != ERR_SUCCESS ) return ERR_FAILURE ; char * script_content = BP_FileGetContents ( path_to_script ) ; if ( ! script_content ) return ERR_FAILURE ; if ( BP_JSRunScript ( mgr , script_content , bpstrlen ( script_content ) - 1 ) == ERR_FAILURE ) return ERR_FAILURE ; return ERR_SUCCESS ; }
Attempts to run a script from a given file path.
Attempts to run a script from a given file path .
// ensure we have a script path // ensure the path is reasonable // ensure the script exists // retrieve script content // ensure we have script content // run the script // return indicating success