private boolean createDestinationDirectory() {
    final DiffMetadata metaData = diff.getMetadata();

    String imagePart =
        String.format(
            "%s vs %s",
            metaData.getImageName(ESide.PRIMARY), metaData.getImageName(ESide.SECONDARY));
    final String separator = " - ";
    final String hashPart =
        String.format(
            "%s-%s", metaData.getImageHash(ESide.PRIMARY), metaData.getImageHash(ESide.SECONDARY));

    final int length = imagePart.length() + separator.length() + hashPart.length();

    if (length > 254) {
      final int delta = length - 254;
      imagePart = imagePart.substring(0, imagePart.length() - 1 - delta);
    }

    String destinationDirectoryPath = FileUtils.ensureTrailingSlash(destinationDir.getPath());
    destinationDirectoryPath += String.format("%s%s%s", imagePart, separator, hashPart);

    destinationDir = new File(destinationDirectoryPath);

    if (!destinationDir.exists()) {
      return destinationDir.mkdir();
    }

    return true;
  }
Save dialog for function diff views.
java/ui/src/main/java/com/google/security/zynamics/bindiff/gui/dialogs/SaveFunctionDiffViewDialog.java