| 45 | } |
| 46 | |
| 47 | std::optional<std::wstring> UWP::GetPackageFullName() |
| 48 | { |
| 49 | static constexpr std::wstring_view FAILED_TO_GET = L"Failed to get package full name"; |
| 50 | |
| 51 | UINT32 length = 0; |
| 52 | LONG result = GetCurrentPackageFullName(&length, nullptr); |
| 53 | if (result != ERROR_INSUFFICIENT_BUFFER) [[unlikely]] |
| 54 | { |
| 55 | if (result == APPMODEL_ERROR_NO_PACKAGE) |
| 56 | { |
| 57 | return std::nullopt; |
| 58 | } |
| 59 | else |
| 60 | { |
| 61 | HresultHandle(HRESULT_FROM_WIN32(result), spdlog::level::critical, FAILED_TO_GET); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | std::wstring familyName; |
| 66 | familyName.resize_and_overwrite(length - 1, [](wchar_t* data, std::size_t count) |
| 67 | { |
| 68 | UINT32 length = static_cast<UINT32>(count) + 1; |
| 69 | const LONG result = GetCurrentPackageFullName(&length, data); |
| 70 | if (result != ERROR_SUCCESS) [[unlikely]] |
| 71 | { |
| 72 | HresultHandle(HRESULT_FROM_WIN32(result), spdlog::level::critical, FAILED_TO_GET); |
| 73 | } |
| 74 | |
| 75 | return length - 1; |
| 76 | }); |
| 77 | |
| 78 | return familyName; |
| 79 | } |
| 80 | |
| 81 | std::optional<std::filesystem::path> UWP::GetAppStorageFolder() |
| 82 | { |
nothing calls this directly
no outgoing calls
no test coverage detected