Skip to content
This repository has been archived by the owner on Jul 30, 2020. It is now read-only.

Commit

Permalink
Fix up on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Spain committed Jun 9, 2018
1 parent d69f9cd commit 31bfc04
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/platform_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#include <fcntl.h>
#include <io.h>
#include <windows.h>
#include <Shlobj.h>
#include <Objbase.h>
#include <Knownfolders.h>

#include <sys/stat.h>
#include <sys/types.h>
Expand All @@ -17,6 +20,8 @@
#include <cassert>
#include <iostream>
#include <string>
#include <locale>
#include <codecvt>

namespace {
void EmitError(const std::string& message) {
Expand Down Expand Up @@ -353,7 +358,7 @@ optional<std::string> RunExecutable(const std::vector<std::string>& command,

optional<std::string> GetGlobalConfigDirectory() {
wchar_t *roaming_path = NULL;
optional<std::string> cfg_path = std::nullopt;
optional<std::string> cfg_path = {};
if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_RoamingAppData, KF_FLAG_DEFAULT,
NULL, &roaming_path))) {
std::wstringstream roaming_stream;
Expand All @@ -363,10 +368,10 @@ optional<std::string> GetGlobalConfigDirectory() {
// is analogous with the string returned by the posix version.
using convert_type = std::codecvt_utf8<wchar_t>;
std::wstring_convert<convert_type, wchar_t> converter;
cfg_path = converter.to_bytes(roaming_stream.str())
cfg_path = converter.to_bytes(roaming_stream.str());
}
CoTaskMemFree(static_cast<void*>(roaming_path));
return cfg_path
return cfg_path;
}

#endif

0 comments on commit 31bfc04

Please sign in to comment.