trialName = experiment.getTrials()[currentTrial].getShortName();
Trial[] trials = experiment.getTrials(); if (currentTrial < trials.length) { trialName = trials[currentTrial].getShortName(); } else { if (log.isWarnEnabled()) log.warn("Bug 2072 in makeResultDirectory: currentTrial >= # trials? currentTrial=" + currentTrial + ", trials.length=" + trials.length); currentTrial--; }
  private String makeResultDirectory() {    // defaults, if we don't have an experiment    File resultDir = csmart.getResultDir();    String experimentName = "Experiment";    String trialName = "Trial 1";    if (experiment != null && usingExperiment && currentTrial >= 0) {      resultDir = experiment.getResultDirectory();      experimentName = experiment.getExperimentName();      trialName = experiment.getTrials()[currentTrial].getShortName();    }    // if user didn't specify results directory, save in local directory    if (resultDir == null)      return null;    String dirname = resultDir.getAbsolutePath() + File.separatorChar +       experimentName + File.separatorChar +      trialName + File.separatorChar +      "Results-" + fileDateFormat.format(runStart);    try {      File f = new File(dirname);      // guarantee that directories exist      if (!f.exists() && !f.mkdirs() && !f.exists())         return null;    } catch (Exception e) {      if(log.isErrorEnabled()) {        log.error("Couldn't create results directory " + dirname + ": ", e);      }      return null;    }    return dirname;  }