diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2004-11-09 12:53:51 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2004-11-09 12:53:51 +0000 |
commit | abba18ccb4ba1ef9b3a27267cfe61deb37338f82 (patch) | |
tree | 163ecce05b008b36d4126f0978bb5fecfa2848da /stoc | |
parent | 824996f4eeaa756528cd617ec60daabd0c045b94 (diff) |
INTEGRATION: CWS jl13 (1.14.24); FILE MERGED
2004/09/30 15:34:59 jl 1.14.24.1: #i29390# some cleanup
Diffstat (limited to 'stoc')
-rw-r--r-- | stoc/source/javavm/jvmargs.cxx | 234 |
1 files changed, 5 insertions, 229 deletions
diff --git a/stoc/source/javavm/jvmargs.cxx b/stoc/source/javavm/jvmargs.cxx index a5639c967b01..2de73bb3ea3a 100644 --- a/stoc/source/javavm/jvmargs.cxx +++ b/stoc/source/javavm/jvmargs.cxx @@ -2,9 +2,9 @@ * * $RCSfile: jvmargs.cxx,v $ * - * $Revision: 1.14 $ + * $Revision: 1.15 $ * - * last change: $Author: obo $ $Date: 2004-06-01 09:04:23 $ + * last change: $Author: hr $ $Date: 2004-11-09 13:53:51 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,32 +59,14 @@ * ************************************************************************/ -#ifdef UNIX -#define CLASSPATH_DELIMETER ":" - -#else -#define CLASSPATH_DELIMETER ";" - -#endif - - -#include <string.h> - #include "jvmargs.hxx" -#include "com/sun/star/uno/Exception.hpp" -#include "rtl/bootstrap.hxx" -#include <osl/diagnose.h> -#include <osl/thread.h> -#include "osl/file.h" -#include "osl/file.hxx" - #include <rtl/ustring.hxx> -#include <rtl/ustrbuf.hxx> + #define OUSTR(x) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( x )) using namespace rtl; -namespace css = com::sun::star; + namespace stoc_javavm { JVM::JVM() throw()//: _enabled(sal_False) @@ -98,30 +80,7 @@ void JVM::pushProp(const OUString & property) { OUString left = property.copy(0, index).trim(); OUString right(property.copy(index + 1).trim()); - -// if(left.equals(OUString(RTL_CONSTASCII_USTRINGPARAM("Enable")))) -// { -// setEnabled(right.toInt32()); -// } -// else - if(left.equals(OUString(RTL_CONSTASCII_USTRINGPARAM("Version")))) - { - setVersion(right); - } - else if(left.equals(OUString(RTL_CONSTASCII_USTRINGPARAM("Home")))) - { - setJavaHome(right); - } - else if (left.equals(OUString(RTL_CONSTASCII_USTRINGPARAM("ApplicationClassesDir")))) - { - setApplicationClassesDir(right); - } - else if(left.equals(OUString(RTL_CONSTASCII_USTRINGPARAM("RuntimeLib")))) - { - setRuntimeLib(right); - } - else - _props.push_back(property); + _props.push_back(property); } else { // no '=', could be -X @@ -129,193 +88,10 @@ void JVM::pushProp(const OUString & property) } } -void JVM::setApplicationClassesDir(const rtl::OUString & sDir) -{ - rtl::OUString sPaths = buildClassPathFromDirectory(sDir); - addClassPath(sPaths); -} -/** The path has the form: foo/bar - That is, separator is a slash. - @exception com::sun::star::uno::Exception - */ -rtl::OUString JVM::buildClassPathFromDirectory(const rtl::OUString & relPath) -{ - rtl::OUString sInstallDir; - rtl::Bootstrap::get(OUSTR("BaseInstallation"), - sInstallDir, - OUSTR("${$SYSBINDIR/" SAL_CONFIGFILE("bootstrap") ":BaseInstallation}")); - rtl::OUString sClassesDir = sInstallDir + OUSTR("/") + relPath; - - osl::Directory dir(sClassesDir); - osl::FileBase::RC fileErrorCode; - if ((fileErrorCode = dir.open()) != osl::FileBase::E_None) -// if ((fileErrorCode = dir.open()) != osl::FileBase::RC::E_None) - { - rtl::OUString sMsg(OUSTR("[javavm.cxx]File operation failed. Error: ") - + rtl::OUString::valueOf((sal_Int32) fileErrorCode)); - throw css::uno::Exception(sMsg, 0); - } - - osl::DirectoryItem dirItem; - rtl::OUStringBuffer sBuffer(2048); - char szSep[] = {SAL_PATHSEPARATOR,0}; - - //insert the path to the directory, so that .class files can be found - rtl::OUString sDirPath; - if ((fileErrorCode = osl::FileBase::getSystemPathFromFileURL( - sClassesDir, sDirPath)) - != osl::FileBase::E_None) - { - rtl::OUString sMsg(OUSTR("[javavm.cxx]File operation failed. Error: ") - + rtl::OUString::valueOf((sal_Int32) fileErrorCode)); - throw css::uno::Exception(sMsg, 0); - } - sBuffer.append(sDirPath); - sBuffer.appendAscii(szSep); - - rtl::OUString sJarExtension(OUSTR(".jar")); - sal_Int32 nJarExtensionLength = sJarExtension.getLength(); - for(;;) - { - fileErrorCode = dir.getNextItem(dirItem); - if (fileErrorCode == osl::FileBase::E_None) - { - osl::FileStatus stat(FileStatusMask_All); - if ((fileErrorCode = dirItem.getFileStatus(stat)) != - osl::FileBase::E_None) - { - rtl::OUString sMsg(OUSTR("[javavm.cxx]File operation failed. Error: ") - + rtl::OUString::valueOf( - (sal_Int32) fileErrorCode)); - throw css::uno::Exception(sMsg, 0); - } - // check if the item is a file. - switch (stat.getFileType()) - { - case osl::FileStatus::Regular: - break; - case osl::FileStatus::Link: - { - rtl::OUString sLinkURL = stat.getLinkTargetURL(); - osl::DirectoryItem itemLink; - if (osl::DirectoryItem::get(sLinkURL, itemLink) - != osl::FileBase::E_None) - { - throw css::uno::Exception(); - } - osl::FileStatus statLink(FileStatusMask_All); - if (statLink.getFileType() != osl::FileStatus::Regular) - continue; - //ToDo check if the link is also a regular file: - break; - } - default: - continue; - } - - //check if the file is a .jar, class files are ignored - rtl::OUString sFileName = stat.getFileName(); - sal_Int32 len = sFileName.getLength(); - sal_Int32 nIndex = sFileName.lastIndexOf(sJarExtension); - if ((nIndex == -1) - || (nIndex + nJarExtensionLength != len)) - continue; - - rtl::OUString sFileURL = stat.getFileURL(); - rtl::OUString sFilePath; - if ((fileErrorCode = osl::FileBase::getSystemPathFromFileURL( - sFileURL, sFilePath)) - != osl::FileBase::E_None) - { - rtl::OUString sMsg(OUSTR("[javavm.cxx]File operation failed. Error: ") - + rtl::OUString::valueOf( - (sal_Int32) fileErrorCode)); - throw css::uno::Exception(sMsg, 0); - } - sBuffer.append(sFilePath); - sBuffer.appendAscii(szSep); - } - else if (fileErrorCode == osl::FileBase::E_NOENT) - { - break; - } - else - { - rtl::OUString sMsg(OUSTR("File operation failed. Error:") - + rtl::OUString::valueOf( - (sal_Int32) fileErrorCode)); - throw css::uno::Exception(); - } - } - return sBuffer.makeStringAndClear(); -} - -void JVM::setVersion(const rtl::OUString & sVersion) -{ - _version = sVersion; -} - -const ::rtl::OUString & JVM::getVersion() const -{ - return _version; -} - -void JVM::setJavaHome(const ::rtl::OUString & sHomeUrl) -{ - // we need a system path and not a file URL - OUString usSysPath; - oslFileError er= osl_getSystemPathFromFileURL( sHomeUrl.pData, &usSysPath.pData); - _java_home = usSysPath; -} - -// void JVM::setEnabled(sal_Bool sbFlag) -// { -// _enabled = sbFlag; -// } - -void JVM::addClassPath(const OUString & classpath) -{ - if( classpath.getLength() ) - { - OUStringBuffer buf(_classpath.getLength() +1 + classpath.getLength()); - if( _classpath.getLength() ) - { - buf.append( _classpath ); - buf.appendAscii( CLASSPATH_DELIMETER ); - } - buf.append( classpath ); - _classpath = buf.makeStringAndClear(); - } -} - - -void JVM::setRuntimeLib(const OUString & libName) -{ - _runtimeLib = libName; -} - -const OUString & JVM::getRuntimeLib() const -{ - return _runtimeLib; -} - -// sal_Bool JVM::isEnabled() const -// { -// return _enabled; -// } - -rtl::OUString JVM::getClassPath() const -{ - return _classpath; -} const ::std::vector< ::rtl::OUString > & JVM::getProperties() const { return _props; } -const OUString& JVM::getJavaHome() const -{ - return _java_home; -} } |