* @param defaults
   * @return String
   */
  public static String mergeFileNames(String basefile, String defaults) {
    { char baseseparator = Stella.directorySeparatorForFile(basefile);
      String basehost = Stella.getLogicalHostName(basefile);
      String basedirectory = Stella.logicalPathnameWithoutHost(Stella.fileNameDirectory(basefile));
      String basename = Stella.fileBaseName(basefile);
      String baseextension = Stella.fileExtension(basefile);
      char defaultsseparator = Stella.directorySeparatorForFile(defaults);
      boolean mergedP = false;
      OutputStringStream result = null;

      if ((!(baseseparator == defaultsseparator)) &&
          (Native.string_memberP(basefile, baseseparator) &&
           Native.string_memberP(defaults, defaultsseparator))) {
        throw ((StellaException)(StellaException.newStellaException("merge-file-names: base file and defaults use different syntax").fillInStackTrace()));
      }
      if (basehost == null) {
        basehost = Stella.getLogicalHostName(defaults);
        mergedP = mergedP ||
            (basehost != null);
      }
      if (Stella.stringEqlP(basedirectory, "")) {
        basedirectory = Stella.logicalPathnameWithoutHost(Stella.fileNameDirectory(defaults));
        mergedP = mergedP ||
            (!Stella.stringEqlP(basedirectory, ""));
      }
      if (basename == null) {
        basename = Stella.fileBaseName(defaults);
        mergedP = mergedP ||
            (basename != null);
      }
      if (baseextension == null) {
        baseextension = Stella.fileExtension(defaults);
        mergedP = mergedP ||
            (baseextension != null);
      }
      if (!mergedP) {
        return (basefile);
      }
      result = OutputStringStream.newOutputStringStream();
      if (basehost != null) {
        result.nativeStream.print(basehost + Stella.LOGICAL_HOST_SEPARATOR);
      }
      result.nativeStream.print(basedirectory);
      if (basename != null) {
        result.nativeStream.print(basename);
      }
      if (baseextension != null) {
        result.nativeStream.print(baseextension);
      }
      return (result.theStringReader());
    }
  }