1*1789df15SXin Li /* 2*1789df15SXin Li * Copyright (C) 2014 The Android Open Source Project 3*1789df15SXin Li * 4*1789df15SXin Li * Licensed under the Apache License, Version 2.0 (the "License"); 5*1789df15SXin Li * you may not use this file except in compliance with the License. 6*1789df15SXin Li * You may obtain a copy of the License at 7*1789df15SXin Li * 8*1789df15SXin Li * http://www.apache.org/licenses/LICENSE-2.0 9*1789df15SXin Li * 10*1789df15SXin Li * Unless required by applicable law or agreed to in writing, software 11*1789df15SXin Li * distributed under the License is distributed on an "AS IS" BASIS, 12*1789df15SXin Li * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*1789df15SXin Li * See the License for the specific language governing permissions and 14*1789df15SXin Li * limitations under the License. 15*1789df15SXin Li */ 16*1789df15SXin Li 17*1789df15SXin Li #pragma once 18*1789df15SXin Li 19*1789df15SXin Li 20*1789df15SXin Li #include <set> // STL std::set 21*1789df15SXin Li #include "JavaPath.h" 22*1789df15SXin Li 23*1789df15SXin Li class CJavaFinder { 24*1789df15SXin Li public: 25*1789df15SXin Li // Creates a new JavaFinder. 26*1789df15SXin Li // minVersion to accept, using JAVA_VERS_TO_INT macro. 0 to accept everything. 27*1789df15SXin Li CJavaFinder(int minVersion = 0); 28*1789df15SXin Li ~CJavaFinder(); 29*1789df15SXin Li getMinVersion()30*1789df15SXin Li int getMinVersion() const { return mMinVersion; } 31*1789df15SXin Li 32*1789df15SXin Li // Returns the path recorded in the registry. 33*1789df15SXin Li // If there is no path or it is no longer valid, returns an empty string. 34*1789df15SXin Li CJavaPath getRegistryPath(); 35*1789df15SXin Li 36*1789df15SXin Li // Sets the given path as the default to use in the registry. 37*1789df15SXin Li // Returns true on success. 38*1789df15SXin Li bool setRegistryPath(const CJavaPath &javaPath); 39*1789df15SXin Li 40*1789df15SXin Li // Scans the registry, the environment and program files for potential Java.exe locations. 41*1789df15SXin Li // Fills the given set with the tuples (version, path) found, guaranteed sorted and unique. 42*1789df15SXin Li void findJavaPaths(std::set<CJavaPath> *paths); 43*1789df15SXin Li 44*1789df15SXin Li // Checks the given path for a given java.exe. 45*1789df15SXin Li // Input path variation tried are: path as-is, path/java.exe or path/bin/java.exe. 46*1789df15SXin Li // Places the java path and version in outPath; 47*1789df15SXin Li // Returns true if a java path was found *and* its version is at least mMinVersion. 48*1789df15SXin Li bool checkJavaPath(const CString &path, CJavaPath *outPath); 49*1789df15SXin Li 50*1789df15SXin Li private: 51*1789df15SXin Li int mMinVersion; 52*1789df15SXin Li }; 53