static _PyInitError canonicalize(wchar_t *buffer, const wchar_t *path) { if (buffer == NULL) { return _Py_INIT_NO_MEMORY(); } if (_PathCchCanonicalizeEx_Initialized == 0) { HMODULE pathapi = LoadLibraryW(L"api-ms-win-core-path-l1-1-0.dll"); if (pathapi) { _PathCchCanonicalizeEx = (PPathCchCanonicalizeEx)GetProcAddress(pathapi, "PathCchCanonicalizeEx"); } else { _PathCchCanonicalizeEx = NULL; } _PathCchCanonicalizeEx_Initialized = 1; } if (_PathCchCanonicalizeEx) { if (FAILED(_PathCchCanonicalizeEx(buffer, MAXPATHLEN + 1, path, 0))) { return _Py_INIT_ERR("buffer overflow in getpathp.c's canonicalize()"); } } else { if (!PathCanonicalizeW(buffer, path)) { return _Py_INIT_ERR("buffer overflow in getpathp.c's canonicalize()"); } } return _Py_INIT_OK(); }
void CSalsitaExtensionHelper::ResourcesDirGetDebugPath(const wchar_t *preprocessorDefinedPath, std::wstring &result) { result.assign(preprocessorDefinedPath); std::replace(result.begin(), result.end(), L'/', L'\\'); std::wstring canonicalized; canonicalized.resize(MAX_PATH+1); PathCanonicalizeW((LPWSTR)canonicalized.c_str(), result.c_str()); result.assign(canonicalized.c_str()); ResourcesDirNormalize(result); }
/* 010509 Carl Corcoran */ void CCString::Path_Canonicalize() { WCHAR wsz[MAX_PATH]; PathCanonicalizeW(wsz, this->wszString); this->_CreateFromW(wsz); }
bool PathCanonicalize(wchar_t* dst, const wchar_t* src) { return PathCanonicalizeW(dst, src); }