Bazel client: split CanAccess to specific methods
The new methods (CanReadFile, CanExecuteFile,
CanAccessDirectory) are a lot easier to implement
on Windows than a generic CanAccess. On POSIX
these methods are just a wrapper around the now
static-visible CanAccess().
See https://github.com/bazelbuild/bazel/issues/2107
--
PiperOrigin-RevId: 144176710
MOS_MIGRATED_REVID=144176710
diff --git a/src/main/cpp/startup_options.cc b/src/main/cpp/startup_options.cc
index c69cf0b..f824360 100644
--- a/src/main/cpp/startup_options.cc
+++ b/src/main/cpp/startup_options.cc
@@ -354,8 +354,9 @@
}
string StartupOptions::GetJvm() {
- string java_program = blaze_util::JoinPath(GetHostJavabase(), "bin/java");
- if (!blaze_util::CanAccess(java_program, false, false, true)) {
+ string java_program =
+ blaze_util::JoinPath(GetHostJavabase(), GetJavaBinaryUnderJavabase());
+ if (!blaze_util::CanExecuteFile(java_program)) {
if (!blaze_util::PathExists(java_program)) {
fprintf(stderr, "Couldn't find java at '%s'.\n", java_program.c_str());
} else {
@@ -368,8 +369,8 @@
string jdk_rt_jar = blaze_util::JoinPath(GetHostJavabase(), "jre/lib/rt.jar");
// If just the JRE is installed
string jre_rt_jar = blaze_util::JoinPath(GetHostJavabase(), "lib/rt.jar");
- if (blaze_util::CanAccess(jdk_rt_jar, true, false, false)
- || blaze_util::CanAccess(jre_rt_jar, true, false, false)) {
+ if (blaze_util::CanReadFile(jdk_rt_jar) ||
+ blaze_util::CanReadFile(jre_rt_jar)) {
return java_program;
}
fprintf(stderr, "Problem with java installation: "