diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-12-15 15:10:55 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-12-15 16:45:51 +0100 |
commit | 0136acb836f3451786c4bd9c34dafe66e30d4dda (patch) | |
tree | a717a7023f641f472cc0fd7cf42ed6137da1bc59 /jvmfwk | |
parent | 5d2398a982ea756c99d5f9300b93d61b884eddc4 (diff) |
Rename getJREInfoByPath overload to getAndAddJREInfoByPath
Change-Id: Ib6eac731a4b8193a8d9b9132da78e7961aec22ab
Diffstat (limited to 'jvmfwk')
-rw-r--r-- | jvmfwk/plugins/sunmajor/pluginlib/util.cxx | 52 | ||||
-rw-r--r-- | jvmfwk/plugins/sunmajor/pluginlib/util.hxx | 16 |
2 files changed, 27 insertions, 41 deletions
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx index 567e0116cfe5..621b3581af5f 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx @@ -138,6 +138,26 @@ bool decodeOutput(const OString& s, OUString* out); namespace { + +bool getAndAddJREInfoByPath(const OUString& path, + std::vector<rtl::Reference<VendorBase> > & vecInfos) +{ + bool ret = false; + + rtl::Reference<VendorBase> aInfo = getJREInfoByPath(path); + if (aInfo.is()) + { + ret = true; + vector<rtl::Reference<VendorBase> >::const_iterator it_impl= std::find_if( + vecInfos.begin(),vecInfos.end(), InfoFindSame(aInfo->getHome())); + if(it_impl == vecInfos.end()) + { + vecInfos.push_back(aInfo); + } + } + return ret; +} + OUString getLibraryLocation() { OUString libraryFileUrl; @@ -563,7 +583,7 @@ void createJavaInfoFromWinReg(std::vector<rtl::Reference<VendorBase> > & vecInfo for(ItHome it_home= vecJavaHome.begin(); it_home != vecJavaHome.end(); it_home++) { - getJREInfoByPath(*it_home, vecInfos); + getAndAddJREInfoByPath(*it_home, vecInfos); } } @@ -574,7 +594,7 @@ void createJavaInfoFromWinReg(std::vector<rtl::Reference<VendorBase> > & vecInfo for(ItHome it_home= vecJavaHome.begin(); it_home != vecJavaHome.end(); it_home++) { - getJREInfoByPath(*it_home, vecInfos); + getAndAddJREInfoByPath(*it_home, vecInfos); } } } @@ -764,7 +784,7 @@ void getJREInfoFromBinPath( } if (!sHome.isEmpty()) { - if (getJREInfoByPath(sHome, vecInfos)) + if (getAndAddJREInfoByPath(sHome, vecInfos)) return; } } @@ -806,24 +826,6 @@ vector<OUString> getVectorFromCharArray(char const * const * ar, int size) } return vec; } -bool getJREInfoByPath(const OUString& path, - std::vector<rtl::Reference<VendorBase> > & vecInfos) -{ - bool ret = false; - - rtl::Reference<VendorBase> aInfo = getJREInfoByPath(path); - if (aInfo.is()) - { - ret = true; - vector<rtl::Reference<VendorBase> >::const_iterator it_impl= std::find_if( - vecInfos.begin(),vecInfos.end(), InfoFindSame(aInfo->getHome())); - if(it_impl == vecInfos.end()) - { - vecInfos.push_back(aInfo); - } - } - return ret; -} /** Checks if the path is a directory. Links are resolved. In case of an error the returned string has the length 0. @@ -1186,7 +1188,7 @@ bool makeDriveLetterSame(OUString * fileURL) void createJavaInfoDirScan(vector<rtl::Reference<VendorBase> >& vecInfos) { JFW_TRACE2("Checking /usr/jdk/latest"); - getJREInfoByPath("file:////usr/jdk/latest", vecInfos); + getAndAddJREInfoByPath("file:////usr/jdk/latest", vecInfos); } #elif defined MACOSX && defined X86_64 @@ -1194,7 +1196,7 @@ void createJavaInfoDirScan(vector<rtl::Reference<VendorBase> >& vecInfos) void createJavaInfoDirScan(vector<rtl::Reference<VendorBase> >& vecInfos) { // Oracle Java 7 - getJREInfoByPath("file:///Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home", vecInfos); + getAndAddJREInfoByPath("file:///Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home", vecInfos); } #else @@ -1271,7 +1273,7 @@ void createJavaInfoDirScan(vector<rtl::Reference<VendorBase> >& vecInfos) } JFW_TRACE2("Checking if directory: " << aStatus.getFileURL() << " is a Java"); - getJREInfoByPath(aStatus.getFileURL(),vecInfos); + getAndAddJREInfoByPath(aStatus.getFileURL(),vecInfos); } JFW_ENSURE(errNext == File::E_None || errNext == File::E_NOENT, @@ -1303,7 +1305,7 @@ void createJavaInfoDirScan(vector<rtl::Reference<VendorBase> >& vecInfos) && (islash > RTL_CONSTASCII_LENGTH("file://"))) usDir3 = usDir3.copy(0, islash); - getJREInfoByPath(usDir3,vecInfos); + getAndAddJREInfoByPath(usDir3,vecInfos); } } } diff --git a/jvmfwk/plugins/sunmajor/pluginlib/util.hxx b/jvmfwk/plugins/sunmajor/pluginlib/util.hxx index e8bfb119af70..18232e8eae07 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/util.hxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/util.hxx @@ -95,22 +95,6 @@ struct SameOrSubDirJREMap */ rtl::Reference<VendorBase> getJREInfoByPath(const OUString& path); -/* Creates a VendorBase object if a JRE could be found at the specified path. - - The difference to the other getJREInfoByPath is that this function checks - first if the path corresponds to one of the VendorBase::getHome path already - contained in vecInfo. Only if there is no such entry, then the other - getJREInfoByPath is called. Again the created VendorBase is compared to - those contained in vecInfos. If it is not in there then it's added. - - @return - true a VendorBase was created and added to the end of vecInfos. - false - no VendorBase has been created. Either the path did not represent a - supported JRE installation or there was already a VendorBase in vecInfos. - */ -bool getJREInfoByPath(const OUString& path, - std::vector<rtl::Reference<VendorBase> > & vecInfos); - std::vector<rtl::Reference<VendorBase> > getAllJREInfos(); bool getJavaProps( |