| 606 | } |
| 607 | |
| 608 | std::wstring GetLocalStateFolderPath() |
| 609 | { |
| 610 | static std::wstring CachedResult = ([]() -> std::wstring |
| 611 | { |
| 612 | std::wstring FolderPath; |
| 613 | { |
| 614 | LPWSTR RawFolderPath = nullptr; |
| 615 | // KF_FLAG_FORCE_APP_DATA_REDIRECTION, when engaged, causes |
| 616 | // SHGetKnownFolderPath to return the new AppModel paths |
| 617 | // (Packages/xxx/RoamingState, etc.) for standard path requests. |
| 618 | // Using this flag allows us to avoid |
| 619 | // Windows.Storage.ApplicationData completely. |
| 620 | winrt::check_hresult(::SHGetKnownFolderPath( |
| 621 | FOLDERID_LocalAppData, |
| 622 | KF_FLAG_FORCE_APP_DATA_REDIRECTION, |
| 623 | nullptr, |
| 624 | &RawFolderPath)); |
| 625 | FolderPath = std::wstring(RawFolderPath); |
| 626 | if (!Mile::WinRT::IsPackagedMode()) |
| 627 | { |
| 628 | FolderPath += L"\\M2-Team\\NanaBox"; |
| 629 | } |
| 630 | ::CoTaskMemFree(RawFolderPath); |
| 631 | } |
| 632 | |
| 633 | // Create the directory if it doesn't exist. |
| 634 | ::MileCreateDirectory(FolderPath.c_str()); |
| 635 | |
| 636 | return FolderPath; |
| 637 | }()); |
| 638 | |
| 639 | return CachedResult; |
| 640 | } |
| 641 | |
| 642 | std::wstring GetCurrentProcessModulePath() |
| 643 | { |