Mercurial > minori
diff src/core/filesystem.cpp @ 62:4c6dd5999b39
*: update
1. updated animia
2. use widestrings for filesystem on Windows
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sun, 01 Oct 2023 06:16:06 -0400 |
parents | 327568ad9be9 |
children | 3d2decf093bb |
line wrap: on
line diff
--- a/src/core/filesystem.cpp Fri Sep 29 15:52:31 2023 -0400 +++ b/src/core/filesystem.cpp Sun Oct 01 06:16:06 2023 -0400 @@ -18,6 +18,7 @@ #include "core/filesystem.h" #include "core/config.h" +#include "core/strings.h" #include <limits.h> namespace Filesystem { @@ -36,7 +37,7 @@ end = _path.find(DELIM, start); temp.append(_path.substr(start, end - start)); #ifdef WIN32 - if (!CreateDirectoryA(temp.c_str(), NULL) && GetLastError() == ERROR_PATH_NOT_FOUND) + if (!CreateDirectoryW(Strings::ToWstring(temp).c_str(), NULL) && GetLastError() == ERROR_PATH_NOT_FOUND) /* ERROR_PATH_NOT_FOUND should NOT happen here */ return false; #else @@ -51,7 +52,8 @@ bool Path::Exists() const { #if WIN32 - return GetFileAttributes(_path.c_str()) != INVALID_FILE_ATTRIBUTES; + std::wstring buf = Strings::ToWstring(_path); + return GetFileAttributesW(buf.c_str()) != INVALID_FILE_ATTRIBUTES; #else struct stat st; return stat(_path.c_str(), &st) == 0; @@ -87,9 +89,10 @@ Path GetDotPath(void) { std::string ret = ""; #ifdef WIN32 - char buf[PATH_MAX + 1]; - if (SHGetFolderPathAndSubDir(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, CONFIG_DIR, buf) == S_OK) { - ret += buf; + std::wstring buf(MAX_PATH, '\0'); + if (SHGetFolderPathAndSubDirW(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, CONFIG_WDIR, &buf.front()) == S_OK) { + buf.resize(buf.find('\0')); + ret += Strings::ToUtf8String(buf); } #elif defined(MACOSX) ret += osx::GetApplicationSupportDirectory();