code: def _do_i_own(path: str) -> bool:
      """Return whether the current user owns the given path"""
      p = Path(path).resolve()
  
      # walk up to first existing parent
      while not p.exists() and p != p.parent:
          p = p.parent
  
      # simplest check: owner by name
      # not always implemented or available
      try:
          return p.owner() == os.getlogin()
      except Exception:  # noqa: S110
          pass
  
      if hasattr(os, "geteuid"):
          try:
              st = p.stat()
              return st.st_uid == os.geteuid()
          except (NotImplementedError, OSError):
              # geteuid not always implemented
              pass
  
      # no ownership checks worked, check write access
      return os.access(p, os.W_OK)
  
imports: from __future__ import annotations
  import errno
  import os
  import site
  import stat
  import sys
  import tempfile
  import warnings
  from contextlib import contextmanager
  from pathlib import Path
  from typing import Any, Iterator, Optional
  import platformdirs
  from .utils import deprecation
label_desc: Use image node_id 4 for calling a global function with example usage: _do_i_own(path) and returns: os, unknown, unknown