Skip to content

Commit

Permalink
Documents folder is created if it doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
aseelegbaria committed Jun 10, 2020
1 parent 8594d09 commit 7d0d4ea
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions common/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,19 @@ Some auxillary functionalities might be affected. Please report this message if
res = str;
res += "\\";
}
else if (f == user_documents)
{
//create Documents folder
char* userpath = getenv("USERPROFILE");
std::string path = std::string(userpath) + "\\Documents";
std::wstring pwstrpath = std::wstring(path.begin(), path.end());
LPCWSTR folder_path = pwstrpath.c_str();
SHCreateDirectory(NULL, folder_path);
char str[1024];
wcstombs(str, folder_path, 1023);
res = str;
res += "\\";
}
else
{
throw std::runtime_error("Failed to get requested special folder");
Expand Down

0 comments on commit 7d0d4ea

Please sign in to comment.