Lines Matching +full:path +full:- +full:key
1 /* Return the initial module search path. */
18 # include <mach-o/dyld.h>
62 wchar_t *path; in getpath_abspath() local
67 path = PyUnicode_AsWideCharString(pathobj, &len); in getpath_abspath()
68 if (path) { in getpath_abspath()
70 if (_Py_abspath((const wchar_t *)_Py_normpath(path, -1), &abs) == 0 && abs) { in getpath_abspath()
71 r = PyUnicode_FromWideChar(abs, -1); in getpath_abspath()
74 PyErr_SetString(PyExc_OSError, "failed to make path absolute"); in getpath_abspath()
76 PyMem_Free((void *)path); in getpath_abspath()
85 PyObject *path; in getpath_basename() local
86 if (!PyArg_ParseTuple(args, "U", &path)) { in getpath_basename()
89 Py_ssize_t end = PyUnicode_GET_LENGTH(path); in getpath_basename()
90 Py_ssize_t pos = PyUnicode_FindChar(path, SEP, 0, end, -1); in getpath_basename()
92 return Py_NewRef(path); in getpath_basename()
94 return PyUnicode_Substring(path, pos + 1, end); in getpath_basename()
101 PyObject *path; in getpath_dirname() local
102 if (!PyArg_ParseTuple(args, "U", &path)) { in getpath_dirname()
105 Py_ssize_t end = PyUnicode_GET_LENGTH(path); in getpath_dirname()
106 Py_ssize_t pos = PyUnicode_FindChar(path, SEP, 0, end, -1); in getpath_dirname()
110 return PyUnicode_Substring(path, 0, pos); in getpath_dirname()
119 const wchar_t *path; in getpath_isabs() local
123 path = PyUnicode_AsWideCharString(pathobj, NULL); in getpath_isabs()
124 if (path) { in getpath_isabs()
125 r = _Py_isabs(path) ? Py_True : Py_False; in getpath_isabs()
126 PyMem_Free((void *)path); in getpath_isabs()
139 const wchar_t *path; in getpath_hassuffix() local
145 path = PyUnicode_AsWideCharString(pathobj, &len); in getpath_hassuffix()
146 if (path) { in getpath_hassuffix()
151 wcsicmp(&path[len - suffixLen], suffix) != 0 in getpath_hassuffix()
153 wcscmp(&path[len - suffixLen], suffix) != 0 in getpath_hassuffix()
163 PyMem_Free((void *)path); in getpath_hassuffix()
174 const wchar_t *path; in getpath_isdir() local
178 path = PyUnicode_AsWideCharString(pathobj, NULL); in getpath_isdir()
179 if (path) { in getpath_isdir()
181 DWORD attr = GetFileAttributesW(path); in getpath_isdir()
186 r = (_Py_wstat(path, &st) == 0) && S_ISDIR(st.st_mode) ? Py_True : Py_False; in getpath_isdir()
188 PyMem_Free((void *)path); in getpath_isdir()
200 const wchar_t *path; in getpath_isfile() local
204 path = PyUnicode_AsWideCharString(pathobj, NULL); in getpath_isfile()
205 if (path) { in getpath_isfile()
207 DWORD attr = GetFileAttributesW(path); in getpath_isfile()
212 r = (_Py_wstat(path, &st) == 0) && S_ISREG(st.st_mode) ? Py_True : Py_False; in getpath_isfile()
214 PyMem_Free((void *)path); in getpath_isfile()
226 const wchar_t *path; in getpath_isxfile() local
231 path = PyUnicode_AsWideCharString(pathobj, &cchPath); in getpath_isxfile()
232 if (path) { in getpath_isxfile()
235 DWORD attr = GetFileAttributesW(path); in getpath_isxfile()
238 SUCCEEDED(PathCchFindExtension(path, cchPath + 1, &ext)) && in getpath_isxfile()
239 (CompareStringOrdinal(ext, -1, L".exe", -1, 1 /* ignore case */) == CSTR_EQUAL) in getpath_isxfile()
243 r = (_Py_wstat(path, &st) == 0) && in getpath_isxfile()
248 PyMem_Free((void *)path); in getpath_isxfile()
280 cchFinal = -1; in getpath_joinpath()
288 cchFinal = -1; in getpath_joinpath()
330 PyObject *r = PyUnicode_FromWideChar(_Py_normpath(final, -1), -1); in getpath_joinpath()
341 const wchar_t *path; in getpath_readlines() local
345 path = PyUnicode_AsWideCharString(pathobj, NULL); in getpath_readlines()
346 if (!path) { in getpath_readlines()
349 FILE *fp = _Py_wfopen(path, L"rb"); in getpath_readlines()
350 PyMem_Free((void *)path); in getpath_readlines()
394 Py_ssize_t cb = p2 - p1; in getpath_readlines()
396 --cb; in getpath_readlines()
408 PyObject *u = PyUnicode_FromWideChar(p1, -1); in getpath_readlines()
428 does not resolve any path segments. This is consistent with in getpath_realpath()
433 wchar_t *path = PyUnicode_AsWideCharString(pathobj, NULL); in getpath_realpath() local
434 if (!path) { in getpath_realpath()
437 wchar_t *path2 = _PyMem_RawWcsdup(path); in getpath_realpath()
438 PyMem_Free((void *)path); in getpath_realpath()
439 path = path2; in getpath_realpath()
440 while (path) { in getpath_realpath()
442 int linklen = _Py_wreadlink(path, resolved, Py_ARRAY_LENGTH(resolved)); in getpath_realpath()
443 if (linklen == -1) { in getpath_realpath()
444 r = PyUnicode_FromWideChar(path, -1); in getpath_realpath()
448 PyMem_RawFree((void *)path); in getpath_realpath()
449 path = _PyMem_RawWcsdup(resolved); in getpath_realpath()
451 wchar_t *s = wcsrchr(path, SEP); in getpath_realpath()
455 path2 = _Py_join_relfile(path, resolved); in getpath_realpath()
457 path2 = _Py_normpath(path2, -1); in getpath_realpath()
459 PyMem_RawFree((void *)path); in getpath_realpath()
460 path = path2; in getpath_realpath()
469 if (!path) { in getpath_realpath()
473 PyMem_RawFree((void *)path); in getpath_realpath()
480 wchar_t *path = PyUnicode_AsWideCharString(pathobj, NULL); in getpath_realpath() local
481 if (!path) { in getpath_realpath()
484 narrow = Py_EncodeLocale(path, NULL); in getpath_realpath()
499 if (_Py_wrealpath(path, resolved, MAXPATHLEN) == NULL) { in getpath_realpath()
502 r = PyUnicode_FromWideChar(resolved, -1); in getpath_realpath()
505 PyMem_Free((void *)path); in getpath_realpath()
560 for (PyMethodDef *m = getpath_methods; m->ml_name; ++m) { in funcs_to_dict()
565 if (PyDict_SetItemString(dict, m->ml_name, f) < 0) { in funcs_to_dict()
576 if (PyDict_SetItemString(dict, m2->ml_name, f) < 0) { in funcs_to_dict()
585 /* Add a wide-character string constant to the dict */
587 wchar_to_dict(PyObject *dict, const char *key, const wchar_t *s) in wchar_to_dict() argument
592 u = PyUnicode_FromWideChar(s, -1); in wchar_to_dict()
600 r = PyDict_SetItemString(dict, key, u) == 0; in wchar_to_dict()
608 decode_to_dict(PyObject *dict, const char *key, const char *s) in decode_to_dict() argument
626 r = PyDict_SetItemString(dict, key, u) == 0; in decode_to_dict()
633 env_to_dict(PyObject *dict, const char *key, int and_clear) in env_to_dict() argument
637 assert(strncmp(key, "ENV_", 4) == 0); in env_to_dict()
638 assert(strlen(key) < 64); in env_to_dict()
641 // Quick convert to wchar_t, since we know key is ASCII in env_to_dict()
643 for (const char *p = &key[4]; *p; ++p) { in env_to_dict()
650 u = PyUnicode_FromWideChar(v, -1); in env_to_dict()
656 const char *v = getenv(&key[4]); in env_to_dict()
670 r = PyDict_SetItemString(dict, key, u) == 0; in env_to_dict()
673 r = PyDict_SetItemString(dict, key, Py_None) == 0; in env_to_dict()
679 unsetenv(&key[4]); in env_to_dict()
688 int_to_dict(PyObject *dict, const char *key, int v) in int_to_dict() argument
696 r = PyDict_SetItemString(dict, key, o) == 0; in int_to_dict()
704 winmodule_to_dict(PyObject *dict, const char *key, HMODULE mod) in winmodule_to_dict() argument
716 int r = wchar_to_dict(dict, key, buffer); in winmodule_to_dict()
723 /* Add the current executable's path to the dict */
725 progname_to_dict(PyObject *dict, const char *key) in progname_to_dict() argument
728 return winmodule_to_dict(dict, key, NULL); in progname_to_dict()
730 char *path; in progname_to_dict()
733 path = PyMem_RawMalloc((pathLen + 1) * sizeof(char)); in progname_to_dict()
734 if (!path) { in progname_to_dict()
737 if (_NSGetExecutablePath(path, &pathLen) != 0) { in progname_to_dict()
738 PyMem_RawFree(path); in progname_to_dict()
741 // Only keep if the path is absolute in progname_to_dict()
742 if (path[0] == SEP) { in progname_to_dict()
743 int r = decode_to_dict(dict, key, path); in progname_to_dict()
744 PyMem_RawFree(path); in progname_to_dict()
748 PyMem_RawFree(path); in progname_to_dict()
752 return PyDict_SetItemString(dict, key, Py_None) == 0; in progname_to_dict()
756 /* Add the runtime library's path to the dict */
758 library_to_dict(PyObject *dict, const char *key) in library_to_dict() argument
763 return winmodule_to_dict(dict, key, PyWin_DLLhModule); in library_to_dict()
767 static int modPathInitialized = -1; in library_to_dict()
781 const char *path = NSLibraryNameForModule(pythonModule); in library_to_dict()
782 if (path) { in library_to_dict()
783 strncpy(modPath, path, MAXPATHLEN); in library_to_dict()
790 return decode_to_dict(dict, key, modPath); in library_to_dict()
793 return PyDict_SetItemString(dict, key, Py_None) == 0; in library_to_dict()
805 /* Perform the actual path calculation.
807 When compute_path_config is 0, this only reads any initialised path
811 When compute_path_config is 1, full path calculation is performed.
817 safe because already-configured values are not recalculated. To
830 return PyStatus_Error("cannot calculate path configuration without GIL"); in _PyConfig_InitPathConfig()
910 !funcs_to_dict(dict, config->pathconfig_warnings) || in _PyConfig_InitPathConfig()
927 _PyErr_WriteUnraisableMsg("error evaluating path", NULL); in _PyConfig_InitPathConfig()
928 return PyStatus_Error("error evaluating path"); in _PyConfig_InitPathConfig()