public static void directoryHandler(HttpExchange xchg) {
    { String uripath = HttpExchange.getRequestUriPath(xchg);
      PropertyList options = HttpExchange.getHandlerOptions(xchg);
      String path = ((StringWrapper)(options.lookup(Http.KWD_PATH))).wrapperValue;
      String directory = ((StringWrapper)(options.lookup(Http.KWD_DIRECTORY))).wrapperValue;
      String resolveduri = null;
      boolean isdirectoryP = false;
      String contenttype = Http.getHttpMimeType(Http.KWD_BINARY, null);
      org.powerloom.PrintableStringWriter stream = HttpExchange.getReplyStream(xchg);

      uripath = Stella.stringTrim(Stella.unescapeUrlString(uripath));
      isdirectoryP = Stella.endsWithP(uripath, "/", Stella.NULL_INTEGER);
      if (!(Stella.startsWithP(uripath, path, Stella.NULL_INTEGER))) {
        HttpExchange.generateErrorResponse(xchg, Http.KWD_NOT_FOUND, null);
        return;
      }
      uripath = Native.string_subsequence(uripath, path.length(), Stella.NULL_INTEGER);
      if (Stella.startsWithP(uripath, "../", Stella.NULL_INTEGER) ||
          (Stella.startsWithP(uripath, "/..", Stella.NULL_INTEGER) ||
           (Native.stringSearch(uripath, "/../", Stella.NULL_INTEGER) != Stella.NULL_INTEGER))) {
        HttpExchange.generateErrorResponse(xchg, Http.KWD_FORBIDDEN, null);
        return;
      }
      resolveduri = Native.string_substitute(uripath, Stella.directorySeparator(), '/');
      resolveduri = directory + resolveduri;
      if (isdirectoryP) {
        if (Stella.probeFileP(resolveduri + "index.html")) {
          resolveduri = resolveduri + "index.html";
        }
        else if (Stella.probeFileP(resolveduri + "index.htm")) {
          resolveduri = resolveduri + "index.htm";
        }
        else {
          HttpExchange.generateErrorResponse(xchg, Http.KWD_FORBIDDEN, null);
          return;
        }
      }
      if (!(Stella.probeFileP(resolveduri))) {
        HttpExchange.generateErrorResponse(xchg, Http.KWD_NOT_FOUND, null);
        return;
      }
      contenttype = Http.guessFileContentType(resolveduri);
      HttpExchange.setReplyHeaderValue(xchg, Http.KWD_CONTENT_TYPE, contenttype);
      { InputFileStream in = null;

        try {
          in = Stella.openInputFile(resolveduri, Stella.NIL);
          { OutputStream self000 = OutputStream.newOutputStream();

            self000.nativeStream = stream;
            InputStream.copyStreamToStream(in, self000);
          }

        } finally {
          if (in != null) {
            in.free();
          }
        }
      }
    }
  }