class AdbPathUtil {

  @NotNull
  public static String getEscapedPath(@NotNull String path) {
    // Special case for root
    if (FILE_SEPARATOR.equals(path)) {
      return path;
    }

    // Escape each segment, then re-join them by file separator
    return getSegments(path)
      .stream()
      .map(x -> FILE_SEPARATOR + FileListingService.FileEntry.escape(x))
      .collect(Collectors.joining());
  }

}