// file: $isip/class/algo/Output/out_07.cc
// version: $Id: out_07.cc 9260 2003-07-04 19:48:06Z gao $
//

// isip include files
//
#include "Output.h"

// method: transformName
//
// arguments:
//
// return: a boolean value indicating status
//
// this method transforms the input filename into an output filename
// given the specified transformation rules.
//
boolean Output::transformName() {

  // clear the content of the output filename
  //
  output_filename_d.clear();

  // get the extension of the input filename
  //
  String extension;
  input_filename_d.getExt(extension);

  Filename temp;
  
  if (output_basename_d.length() > 0) {
    temp.assign(output_basename_d);
    temp.concat(Filename::DOT);
    temp.concat(output_extension_d);
  }
  else {
    temp.assign(input_filename_d);
  }

  // if no output directory is specified, just transform the name
  // uniquely
  //
  if (output_directory_d.length() == 0) {

    if (extension.eq(output_extension_d) && output_suffix_d.length() == 0)
      output_filename_d.transformUniquely(temp);
    else {
      output_filename_d.assign(temp);
      output_filename_d.transform(output_extension_d, output_suffix_d);
    }
  }

  // output directory specified, so combine the old name (truncated by
  // the number of directory levels to preserve) with the new
  // directory.
  //
  else {
    output_filename_d.assign(temp);
    output_filename_d.transform(output_directory_d, output_extension_d,
				output_suffix_d, output_preserve_d);
  }

  output_filename_d.transformUniquely();
    
  // now use buildPath to make sure the output path exists
  //
  String dir;
  output_filename_d.getDir(dir);
  
  if (dir.length() > 0) {
    Filename::buildPath(dir);
  }

  // exit gracefully
  //
  return true;
}





