rpcs3/Utilities/rPlatform.cpp

59 lines
1.2 KiB
C++
Raw Normal View History

#include "stdafx.h"
#include "restore_new.h"
2015-01-25 16:23:24 +00:00
#pragma warning(disable : 4996)
#include <wx/image.h>
#include "define_new_memleakdetect.h"
#ifndef _WIN32
#include <dirent.h>
#endif
2014-08-24 17:42:19 +00:00
#include "rPlatform.h"
rImage::rImage()
{
handle = static_cast<void*>(new wxImage());
}
rImage::~rImage()
{
delete static_cast<wxImage*>(handle);
}
void rImage::Create(int width, int height, void *data, void *alpha)
{
static_cast<wxImage*>(handle)->Create(width, height, static_cast<unsigned char*>(data), static_cast<unsigned char*>(alpha));
}
void rImage::SaveFile(const std::string& name, rImageType type)
{
if (type == rBITMAP_TYPE_PNG)
{
static_cast<wxImage*>(handle)->SaveFile(fmt::FromUTF8(name),wxBITMAP_TYPE_PNG);
}
else
{
throw std::string("unsupported type");
}
}
std::string rPlatform::getConfigDir()
{
static std::string dir = ".";
if (dir == ".") {
#ifdef _WIN32
dir = "";
//mkdir(dir.c_str());
#else
if (getenv("XDG_CONFIG_HOME") != NULL)
dir = getenv("XDG_CONFIG_HOME");
else if (getenv("HOME") != NULL)
dir = getenv("HOME") + std::string("/.config");
else // Just in case
dir = "./config";
dir = dir + "/rpcs3/";
2014-08-29 13:06:58 +00:00
mkdir(dir.c_str(), 0777);
#endif
}
return dir;
}