static List getLocationsFromPath()

in appengine-plugins-core/src/main/java/com/google/cloud/tools/appengine/operations/cloudsdk/PathResolver.java [85:114]


  static List<String> getLocationsFromPath(String pathEnv) {
    List<String> possiblePaths = new ArrayList<>();

    if (pathEnv != null) {
      for (String path : Splitter.on(File.pathSeparator).split(pathEnv)) {
        // Windows sometimes quotes paths so we need to strip these.
        // However quotes are legal in Unix paths.
        if (IS_WINDOWS) {
          path = unquote(path);
        }
        // strip out trailing path separator
        if (path.endsWith(File.separator)) {
          path = path.substring(0, path.length() - 1);
        }
        if (path.endsWith("google-cloud-sdk" + File.separator + "bin")) {
          possiblePaths.add(path.substring(0, path.length() - 4));
        }

        try {
          Path possibleLink = Paths.get(path, "gcloud");
          if (Files.isSymbolicLink(possibleLink)) {
            getLocationsFromLink(possiblePaths, possibleLink);
          }
        } catch (InvalidPathException ex) {
          // not a possible path
        }
      }
    }
    return possiblePaths;
  }