This commit is contained in:
maelle 2016-03-25 18:42:22 +01:00
commit b527c9b587
1 changed files with 6 additions and 5 deletions

View File

@ -1,6 +1,7 @@
#include "resource_manager.hpp" #include "resource_manager.hpp"
#include "whereami.h" #include "whereami.h"
#include <iostream> #include <iostream>
#include <memory>
#ifdef _WIN32 #ifdef _WIN32
#define FILE_SEP '\\' #define FILE_SEP '\\'
@ -18,15 +19,15 @@ ResourceManager::~ResourceManager() {
*/ */
std::string getCurrentDirectory() { std::string getCurrentDirectory() {
int length = wai_getExecutablePath(NULL, 0, NULL), dirname_length; int length = wai_getExecutablePath(NULL, 0, NULL), dirname_length;
char* buffer = new char[length + 1]; std::unique_ptr<char> buffer = std::unique_ptr<char>(new char[length + 1]);
wai_getExecutablePath(buffer, length, &dirname_length); wai_getExecutablePath(buffer.get(), length, &dirname_length);
if (dirname_length == 0) { if (dirname_length == 0) {
throw std::runtime_error("Impossible de déterminer le chemin actuel"); throw std::runtime_error("Impossible de déterminer le chemin actuel");
} }
buffer[length] = '\0'; buffer.get()[length] = '\0';
return std::string(buffer).substr(0, dirname_length); return std::string(buffer.get()).substr(0, dirname_length);
} }
sf::Texture& ResourceManager::getTexture(std::string name) { sf::Texture& ResourceManager::getTexture(std::string name) {