Sha256: 9d2456142e61ac0c24bfe635eee1dee8b429f2f48bf967c4898473f64fafcd84
Contents?: true
Size: 1.01 KB
Versions: 13
Compression:
Stored size: 1.01 KB
Contents
#include <Gosu/Directories.hpp> #include <Gosu/WinUtility.hpp> #include <cwchar> #include <stdexcept> #include <shlobj.h> namespace { std::wstring specialFolderPath(int csidl) { WCHAR buf[MAX_PATH + 2]; if (FAILED(SHGetFolderPath(NULL, csidl | CSIDL_FLAG_CREATE, NULL, 0, buf))) throw std::runtime_error("Error getting special folder path"); std::size_t len = std::wcslen(buf); if (buf[len - 1] != L'\\') { buf[len] = L'\\'; buf[len + 1] = 0; } return buf; } } void Gosu::useResourceDirectory() { SetCurrentDirectory(resourcePrefix().c_str()); } std::wstring Gosu::resourcePrefix() { return Win::appDirectory(); } std::wstring Gosu::sharedResourcePrefix() { return Win::appDirectory(); } std::wstring Gosu::userSettingsPrefix() { return specialFolderPath(CSIDL_APPDATA); } std::wstring Gosu::userDocsPrefix() { return specialFolderPath(CSIDL_PERSONAL); }
Version data entries
13 entries across 13 versions & 1 rubygems