Skip to content

Commit f3ab204

Browse files
committed
Merge branch 'fix/folders'
2 parents 9ed5814 + 7e356a0 commit f3ab204

File tree

5 files changed

+28
-47
lines changed

5 files changed

+28
-47
lines changed

IntelPresentMon/AppCef/ipm-ui-vue/src/stores/preferences.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ export const usePreferencesStore = defineStore('preferences', () => {
159159
await hotkeys.bindDefaults();
160160
resetPreferences();
161161
preferences.value.selectedPreset = Preset.Slot1;
162-
console.warn('Preferences reset due to load failure: ' + e)
163-
notes.notify({ text: `Preferences reset due to load failure: ${e}` })
162+
serialize();
163+
console.info('Preferences reset due to load failure: ' + e);
164164
}
165165
}
166166

IntelPresentMon/AppCef/source/util/async/BrowseStoreSpec.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ namespace p2c::client::util::async
1818
// {payload: string} => {written: bool}
1919
void ExecuteOnBrowser(uint64_t uid, CefRefPtr<CefValue> pArgObj, CefRefPtr<CefBrowser> pBrowser) const override
2020
{
21-
using infra::util::FolderResolver;
22-
std::wstring startPath = FolderResolver::Get().Resolve(FolderResolver::Folder::Documents, L"Loadouts\\");
21+
using FR = infra::util::FolderResolver;
22+
std::wstring startPath = FR::Get().Resolve(FR::Folder::Documents, FR::loadoutsSubdirectory);
2323

2424
wchar_t pathBuffer[MAX_PATH] = { 0 };
2525
OPENFILENAMEW ofn{

IntelPresentMon/AppCef/source/util/async/LoadFile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace p2c::client::util::async
2929
}
3030
else {
3131
auto s = std::format("Unable to open file path: {}", filePath.string());
32-
pmlog_error(s);
32+
pmlog_warn(s);
3333
throw std::runtime_error{ s };
3434
}
3535
}

IntelPresentMon/Core/source/infra/util/FolderResolver.cpp

Lines changed: 21 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,14 @@ namespace p2c::infra::util
2525

2626
FolderResolver::FolderResolver(std::wstring appPathSubdir, std::wstring docPathSubdir, bool createSubdirectories)
2727
{
28-
if (!appPathSubdir.empty())
29-
{
28+
if (!appPathSubdir.empty()) {
3029
wchar_t* pPath = nullptr;
31-
if (auto hr = SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, nullptr, &pPath); FAILED(hr))
32-
{
30+
if (auto hr = SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, nullptr, &pPath); FAILED(hr)) {
3331
CoTaskMemFree(pPath);
3432
pPath = nullptr;
3533
pmlog_error("Failed getting local app data path");
3634
throw Except<Exception>();
37-
}
35+
}
3836
const auto dir = std::format(L"{}\\{}", pPath, appPathSubdir);
3937
try {
4038
std::filesystem::create_directories(dir);
@@ -46,26 +44,22 @@ namespace p2c::infra::util
4644
pmlog_error("Failed creating directory: " + str::ToNarrow(dir));
4745
throw Except<Exception>();
4846
}
49-
if (pPath)
50-
{
47+
if (pPath) {
5148
CoTaskMemFree(pPath);
5249
}
5350
}
54-
else
55-
{
51+
else {
5652
appPath = std::filesystem::current_path().wstring();
5753
}
5854

59-
if (!docPathSubdir.empty())
60-
{
55+
if (!docPathSubdir.empty()) {
6156
wchar_t* pPath = nullptr;
62-
if (auto hr = SHGetKnownFolderPath(FOLDERID_Documents, 0, nullptr, &pPath); FAILED(hr))
63-
{
57+
if (auto hr = SHGetKnownFolderPath(FOLDERID_Documents, 0, nullptr, &pPath); FAILED(hr)) {
6458
CoTaskMemFree(pPath);
6559
pPath = nullptr;
6660
pmlog_error("Failed getting user documents path");
6761
throw Except<Exception>();
68-
}
62+
}
6963
const auto dir = std::format(L"{}\\{}", pPath, docPathSubdir);
7064
try {
7165
std::filesystem::create_directories(dir);
@@ -77,13 +71,11 @@ namespace p2c::infra::util
7771
pmlog_error("Failed creating directory: " + str::ToNarrow(dir));
7872
throw Except<Exception>();
7973
}
80-
if (pPath)
81-
{
74+
if (pPath) {
8275
CoTaskMemFree(pPath);
8376
}
8477
}
85-
else
86-
{
78+
else {
8779
docPath = std::filesystem::current_path().wstring();
8880
}
8981

@@ -97,50 +89,39 @@ namespace p2c::infra::util
9789

9890
std::wstring FolderResolver::Resolve(Folder f, std::wstring path) const
9991
{
100-
switch (f)
101-
{
92+
switch (f) {
10293
case Folder::App:
103-
if (appPath.empty())
104-
{
94+
if (appPath.empty()) {
10595
pmlog_error("Failed to resolve app path: not initialized");
10696
throw Except<Exception>();
10797
}
108-
if (path.empty())
109-
{
98+
if (path.empty()) {
11099
return appPath;
111100
}
112-
else
113-
{
101+
else {
114102
return std::format(L"{}\\{}", appPath, path);
115103
}
116-
case Folder::Documents:
117-
{
118-
if (docPath.empty())
119-
{
104+
case Folder::Documents: {
105+
if (docPath.empty()) {
120106
pmlog_error("Failed to resolve documents path: not initialized");
121107
throw Except<Exception>();
122108
}
123-
if (path.empty())
124-
{
109+
if (path.empty()) {
125110
return docPath;
126111
}
127-
else
128-
{
112+
else {
129113
return std::format(L"{}\\{}", docPath, path);
130114
}
131115
}
132-
case Folder::Temp:
133-
{
116+
case Folder::Temp: {
134117
wchar_t tempPath[MAX_PATH + 1];
135-
if (!GetTempPathW(MAX_PATH, tempPath))
136-
{
118+
if (!GetTempPathW(MAX_PATH, tempPath)) {
137119
pmlog_error("failed resolving temp dir").hr();
138120
throw Except<Exception>();
139121
}
140122
return std::format(L"{}{}", tempPath, path);
141123
}
142-
case Folder::Install:
143-
{
124+
case Folder::Install: {
144125
wchar_t modulePath[MAX_PATH];
145126
::GetModuleFileNameW(nullptr, modulePath, (DWORD)std::size(modulePath));
146127
const auto dir = std::filesystem::path{ modulePath }.remove_filename().wstring();

IntelPresentMon/Core/source/kernel/Overlay.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,14 +436,14 @@ namespace p2c::kern
436436
}
437437
else {
438438
const auto folder = FR::Get().Resolve(FR::Folder::Documents, FR::capturesSubdirectory);
439-
fullPath = std::format(L"{0}{1}-{3}-{2:%y}{2:%m}{2:%d}-{2:%H}{2:%M}{2:%OS}.csv",
439+
fullPath = std::format(L"{0}\\{1}-{3}-{2:%y}{2:%m}{2:%d}-{2:%H}{2:%M}{2:%OS}.csv",
440440
folder, pSpec->captureName, now, proc.name);
441441
}
442442
// create optional path for stats file
443443
auto fullStatsPath = [&]() -> std::optional<std::wstring> {
444444
if (pSpec->generateStats) {
445445
const auto folder = FR::Get().Resolve(FR::Folder::Documents, FR::capturesSubdirectory);
446-
return std::format(L"{0}{1}-{3}-{2:%y}{2:%m}{2:%d}-{2:%H}{2:%M}{2:%OS}-stats.csv",
446+
return std::format(L"{0}\\{1}-{3}-{2:%y}{2:%m}{2:%d}-{2:%H}{2:%M}{2:%OS}-stats.csv",
447447
folder, pSpec->captureName, now, proc.name);
448448
}
449449
else {

0 commit comments

Comments
 (0)