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

Version Path
gosu-0.10.7 src/DirectoriesWin.cpp
gosu-0.10.6 src/DirectoriesWin.cpp
gosu-0.10.5 src/DirectoriesWin.cpp
gosu-0.10.5.pre0 src/DirectoriesWin.cpp
gosu-0.10.5.pre1 src/DirectoriesWin.cpp
gosu-0.10.4 src/DirectoriesWin.cpp
gosu-0.10.3 src/DirectoriesWin.cpp
gosu-0.10.2 src/DirectoriesWin.cpp
gosu-0.10.2.pre1 src/DirectoriesWin.cpp
gosu-0.10.1.2 src/DirectoriesWin.cpp
gosu-0.10.1.1 src/DirectoriesWin.cpp
gosu-0.10.1 src/DirectoriesWin.cpp
gosu-0.10.0 src/DirectoriesWin.cpp