class AbstractDir implements DirInterface {

  public static String pathFromURI(String path) {

    if (path.startsWith("file://")) {
      int charToRemove = 7;

      if (path.charAt(7) == '/' && path.charAt(9) == ':') {
        charToRemove++;
      }

      path = path.substring(charToRemove);
      if (path.contains("%")) {
        try {
          path = URLDecoder.decode(path, WaarpStringUtils.UTF8.name());
        } catch (final UnsupportedEncodingException e) {
          logger.warn("Cannot convert filename to UTF-8: " + path);
        } catch (final IllegalArgumentException e) {
          // ignore: it was propably not url-encoded!
        }
      }
    }
    return path;
  }

}