Merge branch 'master' of https://github.com/matteodelabre/projet-cmi
This commit is contained in:
commit
b527c9b587
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue