MCPcopy Create free account
hub / github.com/secdev/scapy / _probe_xdg_folder

Function _probe_xdg_folder

scapy/main.py:67–82  ·  view source on GitHub ↗
(var, default, *cf)

Source from the content-addressed store, hash-verified

65
66
67def _probe_xdg_folder(var, default, *cf):
68 # type: (str, str, *str) -> Optional[pathlib.Path]
69 path = pathlib.Path(os.environ.get(var, default))
70 try:
71 if not path.exists():
72 # ~ folder doesn't exist. Create according to spec
73 # https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
74 # "If, when attempting to write a file, the destination directory is
75 # non-existent an attempt should be made to create it with permission 0700."
76 path.mkdir(mode=0o700, exist_ok=True)
77 except Exception:
78 # There is a gazillion ways this can fail. Most notably, a read-only fs or no
79 # permissions to even check for folder to exist (e.x. privileges were dropped
80 # before scapy was started).
81 return None
82 return path.joinpath(*cf).resolve()
83
84
85def _probe_config_folder(*cf):

Callers 3

_probe_config_folderFunction · 0.85
_probe_cache_folderFunction · 0.85
_probe_share_folderFunction · 0.85

Calls 2

getMethod · 0.45
resolveMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…