/**
  * Return the file containing the VM executable, or {@code null} if it does not exist.
  *
  * @return the file containing the VM executable
  */
 public File getVmExecutable() {
   synchronized (this) {
     if (vmExecutable == null) {
       vmExecutable =
           FileUtilities.verifyExecutable(
               new File(new File(sdkDirectory, BIN_DIRECTORY_NAME), getVmBinaryName()));
     }
   }
   return vmExecutable;
 }
 /**
  * Ensure that the dart VM is executable. If it is not, make it executable and log that it was
  * necessary for us to do so.
  */
 @DartBlockBody({})
 private void ensureVmIsExecutable() {
   File dartVm = getVmExecutable();
   if (dartVm != null) {
     if (!dartVm.canExecute()) {
       FileUtilities.makeExecutable(dartVm);
       AnalysisEngine.getInstance().getLogger().logError(dartVm.getPath() + " was not executable");
     }
   }
 }
 /**
  * Return the file containing the Dartium executable, or {@code null} if it does not exist.
  *
  * @return the file containing the Dartium executable
  */
 public File getDartiumExecutable() {
   synchronized (this) {
     if (dartiumExecutable == null) {
       dartiumExecutable =
           FileUtilities.verifyExecutable(
               new File(getDartiumWorkingDirectory(), getDartiumBinaryName()));
     }
   }
   return dartiumExecutable;
 }
 /**
  * Return the file containing the Pub executable, or {@code null} if it does not exist.
  *
  * @return the file containing the Pub executable
  */
 public File getPubExecutable() {
   synchronized (this) {
     if (pubExecutable == null) {
       pubExecutable =
           FileUtilities.verifyExecutable(
               new File(
                   new File(sdkDirectory, BIN_DIRECTORY_NAME),
                   OSUtilities.isWindows() ? PUB_EXECUTABLE_NAME_WIN : PUB_EXECUTABLE_NAME));
     }
   }
   return pubExecutable;
 }
 /**
  * Return the file containing the dart formatter executable, or {@code null} if it does not exist.
  *
  * @return the file containing the dart formatter executable
  */
 public File getDartFmtExecutable() {
   synchronized (this) {
     if (dartFmtExecutable == null) {
       dartFmtExecutable =
           FileUtilities.verifyExecutable(
               new File(
                   new File(sdkDirectory, BIN_DIRECTORY_NAME),
                   OSUtilities.isWindows()
                       ? DARTFMT_EXECUTABLE_NAME_WIN
                       : DARTFMT_EXECUTABLE_NAME));
     }
   }
   return dartFmtExecutable;
 }
 /**
  * Return the revision number of this SDK, or {@code "0"} if the revision number cannot be
  * discovered.
  *
  * @return the revision number of this SDK
  */
 @Override
 public String getSdkVersion() {
   synchronized (this) {
     if (sdkVersion == null) {
       sdkVersion = DEFAULT_VERSION;
       File revisionFile = new File(sdkDirectory, VERSION_FILE_NAME);
       try {
         String revision = FileUtilities.getContents(revisionFile);
         if (revision != null) {
           sdkVersion = revision.trim();
         }
       } catch (IOException exception) {
         // Fall through to return the default.
       }
     }
   }
   return sdkVersion;
 }
  /**
   * Read all of the configuration files to initialize the library maps.
   *
   * @param useDart2jsPaths {@code true} if the dart2js path should be used when it is available
   * @return the initialized library map
   */
  protected LibraryMap initialLibraryMap(boolean useDart2jsPaths) {

    File librariesFile =
        new File(
            new File(
                new File(new File(getLibraryDirectory(), INTERNAL_DIR), SDK_LIB_METADATA_DIR),
                SDK_LIB_METADATA_LIB_DIR),
            LIBRARIES_FILE);
    if (!librariesFile.exists()) {
      // Fall back to pre SDK reorg location.
      librariesFile = getLegacyLibrariesFile();
    }
    try {
      String contents = FileUtilities.getContents(librariesFile);
      return new SdkLibrariesReader(useDart2jsPaths).readFromFile(librariesFile, contents);
    } catch (Exception exception) {
      AnalysisEngine.getInstance()
          .getLogger()
          .logError(
              "Could not initialize the library map from " + librariesFile.getAbsolutePath(),
              exception);
      return new LibraryMap();
    }
  }