git repos / blockattack-game

commit 8b477c41

sago007 · 2019-05-05 14:40
8b477c41b39ebf4de2b71249daab031113bcefce patch · browse files
parent c85709bd1ccad0243c04078bca59c2e9f6815548

Renamed win32_utf8_to_utf16 to show that it converts to UTF-16 and not from it.

Changed files

M source/code/os.cpp before
diff --git a/source/code/os.cpp b/source/code/os.cpp index 57ec3d1..a55a518 100644 --- a/source/code/os.cpp +++ b/source/code/os.cpp
@@ -55,7 +55,7 @@ void setPathToSaveFiles(const std::string& path) {
}
#if defined(_WIN32)
-static std::wstring win32_utf16_to_utf8(const char* str) {
+static std::wstring win32_utf8_to_utf16(const char* str) {
std::wstring res;
// If the 6th parameter is 0 then WideCharToMultiByte returns the number of bytes needed to store the result.
int actualSize = MultiByteToWideChar(CP_UTF8, 0, str, -1, nullptr, 0);
@@ -101,17 +101,22 @@ std::string defaultPlayerName() {
return ret;
}
-void OsCreateSaveFolder() {
+static void OsCreateFolder(const std::string& path) {
#if defined(__unix__)
- std::string cmd = "mkdir -p '"+getPathToSaveFiles()+"/'";
+ std::string cmd = "mkdir -p '"+path+"/'";
int retcode = system(cmd.c_str());
if (retcode != 0) {
- std::cerr << "Failed to create: " << getPathToSaveFiles()+"/" << "\n";
+ std::cerr << "Failed to create: " << path+"/" << "\n";
}
#elif defined(_WIN32)
//Now for Windows NT/2k/xp/2k3 etc.
- CreateDirectoryW(win32_utf16_to_utf8(pf.getSaveGamesFolder1().c_str()).c_str(), nullptr);
- std::string tempA = getPathToSaveFiles();
- CreateDirectoryW(win32_utf16_to_utf8(tempA.c_str()).c_str(), nullptr);
+ CreateDirectoryW(win32_utf8_to_utf16(pf.getSaveGamesFolder1().c_str()).c_str(), nullptr);
+ std::string tempA = path;
+ CreateDirectoryW(win32_utf8_to_utf16(tempA.c_str()).c_str(), nullptr);
#endif
}
+
+void OsCreateSaveFolder() {
+ std::string path = getPathToSaveFiles();
+ OsCreateFolder(path);
+}