INTEGRATION: CWS jl51 (1.12.18); FILE MERGED

2007/03/01 16:13:52 jl 1.12.18.1: #64281# some JREs were not found
This commit is contained in:
Ivo Hinkelmann
2007-04-17 09:30:32 +00:00
parent ed2a01ab12
commit 5633f6556e

View File

@@ -4,9 +4,9 @@
* *
* $RCSfile: util.cxx,v $ * $RCSfile: util.cxx,v $
* *
* $Revision: 1.12 $ * $Revision: 1.13 $
* *
* last change: $Author: obo $ $Date: 2006-09-16 17:46:48 $ * last change: $Author: ihi $ $Date: 2007-04-17 10:30:32 $
* *
* The Contents of this file are made available subject to * The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1. * the terms of GNU Lesser General Public License Version 2.1.
@@ -778,16 +778,19 @@ bool getJREInfoByPath(const rtl::OUString& path,
return ret; return ret;
} }
/** Checks if the path is a directory. If it is a link to a directory than /** Checks if the path is a directory. Links are resolved.
it is resolved. In case of an error the returned string has the length 0.
In case of an error the returned string has the length 0 Otherwise the returned string is the "resolved" file URL.
*/ */
OUString resolveDirPath(const OUString & path) OUString resolveDirPath(const OUString & path)
{ {
OUString sResolved = path;
OUString ret; OUString ret;
while (1) OUString sResolved;
{ if (File::getAbsoluteFileURL(
rtl::OUString(), path, sResolved) != File::E_None)
return OUString();
//check if this is a valid path and if it is a directory
DirectoryItem item; DirectoryItem item;
if (DirectoryItem::get(sResolved, item) == File::E_None) if (DirectoryItem::get(sResolved, item) == File::E_None)
{ {
@@ -795,71 +798,44 @@ OUString resolveDirPath(const OUString & path)
FileStatusMask_LinkTargetURL | FileStatusMask_LinkTargetURL |
FileStatusMask_FileURL); FileStatusMask_FileURL);
if (item.getFileStatus(status) == File::E_None) if (item.getFileStatus(status) == File::E_None
{ && status.getFileType() == FileStatus::Directory)
FileStatus::Type t = status.getFileType();
if (t == FileStatus::Directory)
{ {
ret = sResolved; ret = sResolved;
break;
}
else if ( t == FileStatus::Link )
{
sResolved = status.getLinkTargetURL();
}
else
{
break;
} }
} }
else else
break; return OUString();
}
else
break;
}
return ret; return ret;
} }
/** Checks if the path is a file. If it is a link to a file than /** Checks if the path is a file. If it is a link to a file than
it is resolved. it is resolved.
In case of an error the returned string has the length 0
*/ */
OUString resolveFilePath(const OUString & path) OUString resolveFilePath(const OUString & path)
{ {
OUString sResolved = path;
OUString ret; OUString ret;
while (1) OUString sResolved;
{
if (File::getAbsoluteFileURL(
rtl::OUString(), path, sResolved) != File::E_None)
return OUString();
//check if this is a valid path to a file or and if it is a link
DirectoryItem item; DirectoryItem item;
if (DirectoryItem::get(sResolved, item) == File::E_None) if (DirectoryItem::get(sResolved, item) == File::E_None)
{ {
FileStatus status(FileStatusMask_Type | FileStatus status(FileStatusMask_Type |
FileStatusMask_LinkTargetURL | FileStatusMask_LinkTargetURL |
FileStatusMask_FileURL); FileStatusMask_FileURL);
if (item.getFileStatus(status) == File::E_None
if (item.getFileStatus(status) == File::E_None) && status.getFileType() == FileStatus::Regular)
{
FileStatus::Type t = status.getFileType();
if (t == FileStatus::Regular)
{ {
ret = sResolved; ret = sResolved;
break;
}
else if ( t == FileStatus::Link )
{
sResolved = status.getLinkTargetURL();
}
else
{
break;
} }
} }
else else
break; return OUString();
}
else
break;
}
return ret; return ret;
} }
@@ -883,6 +859,9 @@ rtl::Reference<VendorBase> getJREInfoByPath(
//check if the directory path is good, that is a JRE was already recognized. //check if the directory path is good, that is a JRE was already recognized.
//Then we need not detect it again //Then we need not detect it again
//For example, a sun JKD contains <jdk>/bin/java and <jdk>/jre/bin/java.
//When <jdk>/bin/java has been found then we need not find <jdk>/jre/bin/java.
//Otherwise we would execute java two times for evers JDK found.
MapIt entry2 = find_if(mapJREs.begin(), mapJREs.end(), MapIt entry2 = find_if(mapJREs.begin(), mapJREs.end(),
SameOrSubDirJREMap(sResolvedDir)); SameOrSubDirJREMap(sResolvedDir));
if (entry2 != mapJREs.end()) if (entry2 != mapJREs.end())
@@ -919,6 +898,7 @@ rtl::Reference<VendorBase> getJREInfoByPath(
sFullPath = sResolvedDir + sFullPath = sResolvedDir +
OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + (*i); OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + (*i);
sFilePath = resolveFilePath(sFullPath); sFilePath = resolveFilePath(sFullPath);
if (sFilePath.getLength() == 0) if (sFilePath.getLength() == 0)
@@ -1022,11 +1002,11 @@ rtl::Reference<VendorBase> getJREInfoByPath(
} }
} }
if (ret.is() == false) if (ret.is() == false)
vecBadPaths.push_back(sResolvedDir); vecBadPaths.push_back(sFilePath);
else else
{ {
JFW_TRACE2(OUSTR("[Java framework] sunjavaplugin"SAL_DLLEXTENSION ": ") JFW_TRACE2(OUSTR("[Java framework] sunjavaplugin"SAL_DLLEXTENSION ": ")
+ OUSTR("Detected another JRE: ") + sResolvedDir + OUSTR("Found JRE: ") + sResolvedDir
+ OUSTR(" \n at: ") + path + OUSTR(".\n")); + OUSTR(" \n at: ") + path + OUSTR(".\n"));
mapJREs.insert(MAPJRE::value_type(sResolvedDir, ret)); mapJREs.insert(MAPJRE::value_type(sResolvedDir, ret));