class_docstr: Simple KV API built on the underlying filesystem.
  
  This is a convenience wrapper around get_filesystem() and working with files.
  Slashes in the path are interpreted as directory delimiters.
class_docstr_tok: ["Simple","KV","API","built","on","the","underlying","filesystem",".","This","is","a","convenience","wrapper","around","get_filesystem","(",")","and","working","with","files",".","Slashes","in","the","path","are","interpreted","as","directory","delimiters","."]
code: def _resolve_path(self, path: str) -> str:
      from pyarrow.fs import LocalFileSystem
  
      if isinstance(self.fs, LocalFileSystem):
          joined = self.root.joinpath(path).resolve()
          # Raises an error if the path is above the root (e.g., "../data" attack).
          joined.relative_to(self.root.resolve())
          return str(joined)
  
      # In this case, we are not a local file system. However, pathlib would
      # still add prefix to the path as if it is a local path when resolving
      # the path, even when the path does not exist at all. If the path exists
      # locally and is a symlink, then pathlib resolves it to the unwanted
      # physical path. This could leak to an attack. Third, if the path was
      # under Windows, "/" becomes "\", which is invalid for non-local stores.
      # So we decide to resolve it mannually.
      def _normalize_path(p: str) -> str:
          # "////bucket//go/./foo///..//.././/bar/./" becomes "bucket/bar"
          segments = []
          for s in p.replace("\\", "/").split("/"):
              if s == "..":
                  if not segments:
                      raise ValueError("Path goes beyond root.")
                  segments.pop()
              elif s not in (".", ""):
                  segments.append(s)
          return "/".join(segments)
  
      root = _normalize_path(str(self.root))
      joined = _normalize_path(str(self.root.joinpath(path)))
      if not joined.startswith(root):
          raise ValueError(f"{joined!r} does not start with {root!r}")
      return joined
  
imports: import os
  import re
  import urllib
  from pathlib import Path
  from typing import TYPE_CHECKING, List, Optional
  from ray._private.client_mode_hook import client_mode_hook
  from ray._private.utils import _add_creatable_buckets_param_if_s3_uri, load_class
  from ray._private.auto_init_hook import wrap_auto_init
label_desc: Use image node_id 8 for calling the KVClient obj's underlying member method code with example usage: obj._resolve_path(path) and returns: joined, str, str