forked from deskflow/deskflow
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use ansi codepage for internal multibyte strings on windows (fixes #976…
- Loading branch information
Showing
12 changed files
with
138 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* barrier -- mouse and keyboard sharing utility | ||
* Copyright (C) 2018 Debauchee Open Source Group | ||
* | ||
* This package is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* found in the file LICENSE that should have accompanied this file. | ||
* | ||
* This package is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "KnownFolderPaths.h" | ||
|
||
#define WIN32_LEAN_AND_MEAN | ||
#include <Windows.h> | ||
#include <Shlobj.h> | ||
|
||
static std::string wide_to_mb(const wchar_t* source, int length) | ||
{ | ||
int ansiLength = WideCharToMultiByte(CP_ACP, 0, source, length, NULL, 0, NULL, NULL); | ||
if (ansiLength > 0) { | ||
std::string ansiString(ansiLength, 0); | ||
ansiLength = WideCharToMultiByte(CP_ACP, 0, source, length, &ansiString[0], ansiLength, NULL, NULL); | ||
if (ansiLength > 0) { | ||
return ansiString; | ||
} | ||
} | ||
return {}; | ||
} | ||
|
||
static std::string known_folder_path(const KNOWNFOLDERID& id) | ||
{ | ||
std::string path; | ||
WCHAR* buffer; | ||
HRESULT result = SHGetKnownFolderPath(id, 0, NULL, &buffer); | ||
if (result == S_OK) { | ||
auto length = lstrlenW(buffer); | ||
path = wide_to_mb(buffer, length); | ||
CoTaskMemFree(buffer); | ||
} | ||
return path; | ||
} | ||
|
||
std::string desktopPath() | ||
{ | ||
return known_folder_path(FOLDERID_Desktop); | ||
} | ||
|
||
std::string localAppDataPath() | ||
{ | ||
return known_folder_path(FOLDERID_LocalAppData); | ||
} | ||
|
||
std::string programDataPath() | ||
{ | ||
return known_folder_path(FOLDERID_ProgramData); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* barrier -- mouse and keyboard sharing utility | ||
* Copyright (C) 2018 Debauchee Open Source Group | ||
* | ||
* This package is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* found in the file LICENSE that should have accompanied this file. | ||
* | ||
* This package is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
|
||
std::string desktopPath(); | ||
std::string localAppDataPath(); | ||
std::string programDataPath(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.