public static boolean containsWindowsShortName(@NotNull String path) {
    if (path.indexOf('~') < 0) {
      return false;
    }

    path = toSystemIndependentName(path);

    int start = 0;
    while (start < path.length()) {
      int end = path.indexOf('/', start);
      if (end < 0) end = path.length();

      // "How Windows Generates 8.3 File Names from Long File Names", https://support.microsoft.com/en-us/kb/142982
      int dot = path.lastIndexOf('.', end);
      if (dot < start) dot = end;
      if (dot - start > 2 && dot - start <= 8 && end - dot - 1 <= 3 &&
          path.charAt(dot - 2) == '~' && Character.isDigit(path.charAt(dot - 1))) {
        return true;
      }

      start = end + 1;
    }
    return false;
  }
public static boolean containsWindowsShortName(@NotNull String path)