language-extensions/R/src/RExtension.cpp
//--------------------------------------------------------------------------------------------------
// Name: InstallExternalLibrary
//
// Description:
//  Installs an external library to the specified directory
//  The library file is expected to be a zip containing the R package
//  which itself could be a zip or tar.gz file.
//
// Returns:
//  SQL_SUCCESS on success, else SQL_ERROR
//
InstallExternalLibrary
Description:
Installs an external library to the specified directory
The library file is expected to be a zip containing the R package
which itself could be a zip or tar.gz file.


InstallExternalLibrary Description : Installs an external library to the specified directory The library file is expected to be a zip containing the R package which itself could be a zip or tar . gz file .
SQLRETURN InstallExternalLibrary(
	SQLGUID    setupSessionId,
	SQLCHAR    *libraryName,
	SQLINTEGER libraryNameLength,
	SQLCHAR    *libraryFile,
	SQLINTEGER libraryFileLength,
	SQLCHAR    *libraryInstallDirectory,
	SQLINTEGER libraryInstallDirectoryLength,
	SQLCHAR    **libraryError,
	SQLINTEGER *libraryErrorLength)
{
	LOG("RExtension::InstallExternalLibrary");
	SQLRETURN result = SQL_ERROR;
	string exceptionString;
	try
	{
		RLibrarySession librarySession;
		librarySession.Init(
			setupSessionId,
			libraryName,
			libraryNameLength);
		result = librarySession.InstallLibrary(
			libraryFile,
			libraryFileLength,
			libraryInstallDirectory,
			libraryInstallDirectoryLength);
	}
	catch (const exception & ex)
	{
		LOG_EXCEPTION(ex);
		exceptionString = string(ex.what());
	}
	catch (...)
	{
		exceptionString = "Unexpected exception in function InstallExternalLibrary().";
		LOG_ERROR(exceptionString);
	}
	if (!exceptionString.empty())
	{
		*libraryErrorLength = exceptionString.length();
		string *pError = new string(exceptionString);
		SQLCHAR *error = const_cast<SQLCHAR*>(static_cast<const SQLCHAR *>
			(static_cast<const void*>(pError->c_str())));
		*libraryError = error;
	}
	return result;
}
SQLRETURN InstallExternalLibrary ( SQLGUID setupSessionId , SQLCHAR * libraryName , SQLINTEGER libraryNameLength , SQLCHAR * libraryFile , SQLINTEGER libraryFileLength , SQLCHAR * libraryInstallDirectory , SQLINTEGER libraryInstallDirectoryLength , SQLCHAR * * libraryError , SQLINTEGER * libraryErrorLength ) { LOG ( " " ) ; SQLRETURN result = SQL_ERROR ; string exceptionString ; try { RLibrarySession librarySession ; librarySession . Init ( setupSessionId , libraryName , libraryNameLength ) ; result = librarySession . InstallLibrary ( libraryFile , libraryFileLength , libraryInstallDirectory , libraryInstallDirectoryLength ) ; } catch ( const exception & ex ) { LOG_EXCEPTION ( ex ) ; exceptionString = string ( ex . what ( ) ) ; } catch ( ... ) { exceptionString = " " ; LOG_ERROR ( exceptionString ) ; } if ( ! exceptionString . empty ( ) ) { * libraryErrorLength = exceptionString . length ( ) ; string * pError = new string ( exceptionString ) ; SQLCHAR * error = const_cast < SQLCHAR * > ( static_cast < const SQLCHAR * > ( static_cast < const void * > ( pError -> c_str ( ) ) ) ) ; * libraryError = error ; } return result ; }
Name: InstallExternalLibrary
Description:
Installs an external library to the specified directory
The library file is expected to be a zip containing the R package
which itself could be a zip or tar.gz file.
Name : InstallExternalLibrary Description : Installs an external library to the specified directory The library file is expected to be a zip containing the R package which itself could be a zip or tar . gz file .