| 1 |
/** |
| 2 |
* Furnace Tracker - multi-system chiptune tracker |
| 3 |
* Copyright (C) 2021-2025 tildearrow and contributors |
| 4 |
* |
| 5 |
* This program is free software; you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation; either version 2 of the License, or |
| 8 |
* (at your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License along |
| 16 |
* with this program; if not, write to the Free Software Foundation, Inc., |
| 17 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 |
*/ |
| 19 |
|
| 20 |
#include "winStuff.h" |
| 21 |
#define WIN32_LEAN_AND_MEAN |
| 22 |
#include <windows.h> |
| 23 |
#include <shlobj.h> |
| 24 |
#include <shlwapi.h> |
| 25 |
#include "../ta-log.h" |
| 26 |
#include "../utfutils.h" |
| 27 |
|
| 28 |
String getWinConfigPath() { |
| 29 |
wchar_t path[4096]; |
| 30 |
WString configPath; |
| 31 |
HRESULT configHR; |
| 32 |
if ((configHR=SHGetFolderPathW(NULL,CSIDL_APPDATA,NULL,0,path))==S_OK) { |
| 33 |
configPath=path; |
| 34 |
configPath+=L"\\furnace"; |
| 35 |
if (!PathIsDirectoryW(configPath.c_str())) { |
| 36 |
logI("creating config dir..."); |
| 37 |
int mkdirRet; |
| 38 |
if ((mkdirRet=SHCreateDirectoryExW(NULL,configPath.c_str(),NULL))!=ERROR_SUCCESS) { |
| 39 |
logW("could not make config dir! (%.8x)",mkdirRet); |
| 40 |
configPath=L"."; |
| 41 |
} |
| 42 |
} |
| 43 |
} else { |
| 44 |
logW("unable to determine config directory! (%.8x)",configHR); |
| 45 |
configPath=L"."; |
| 46 |
} |
| 47 |
return utf16To8(configPath.c_str()); |
| 48 |
} |