class FilepathUtils {

  public static String getParentPath(final String path) {
    if (null == path) {
      return null;
    }

    if (EMPTY_STRING.equals(path) || DIRECTORY_SEPARATOR.equals(path)) {
      return null;
    }

    final int index = path.lastIndexOf(DIRECTORY_SEPARATOR);

    if (0 == index) {
      return DIRECTORY_SEPARATOR;
    } else if (index < 0) {
      return null;
    }

    return path.substring(0, index);
  }

}