Expands any environment variables in the path (like "%USERPROFILE%") and checks whether it points towards an existing directory.
| 51 | /// Expands any environment variables in the path (like "%USERPROFILE%") and checks whether it points towards an existing directory. |
| 52 | /// </summary> |
| 53 | static bool resolve_env_path(std::filesystem::path &path, const std::filesystem::path &base = g_reshade_dll_path.parent_path()) |
| 54 | { |
| 55 | if (path.empty()) |
| 56 | return false; |
| 57 | |
| 58 | WCHAR buf[4096]; |
| 59 | if (ExpandEnvironmentStringsW(path.c_str(), buf, ARRAYSIZE(buf))) |
| 60 | path = buf; |
| 61 | else |
| 62 | return false; |
| 63 | |
| 64 | path = base / path; |
| 65 | |
| 66 | std::error_code ec; |
| 67 | path = std::filesystem::canonical(path, ec); |
| 68 | return !ec && std::filesystem::is_directory(path, ec); |
| 69 | } |
| 70 | |
| 71 | /// <summary> |
| 72 | /// Returns the path that should be used as base for relative paths. |